Testing PHP Locally Is Easy And Free

Since being created in 1994, PHP still remains one of the top languages for web development for a ton of reasons. It’s one of the first languages that I learned and still one of my most used. Depending on the time since writing this article, Pagemend may still be using PHP as the main language for the frontend and backend. I bet the main website is still using WordPress, which is predominantly PHP. I’ll have to check back in on this article in 5 years…

One of the reasons I picked it up is because it’s very easy to learn. I like to call it lazy programming because it’s very forgiving to beginners when it comes to syntax and gives nice, verbose error messages. Another reason it’s great is that it’s very accessible. It’s open-source and free and all you need is an Apache server to get started (or XAMPP).

I’m not sure which came first, but it’s compatible with lots of different computers systems and servers so you don’t need special requirements to get it to run. And because of this, PHP has a huge community around it. There are lots of pre-coded classes, tools, etc that you can find online, and just about any problem you may have will have an answer on StackOverflow.

PHP is also constantly being improved to increase security and speed. It always sucks when something loses developer support and the project just falls behind the times – not with PHP! New versions come out frequently and I’m always happy to see it.

PHP stands for “Hypertext Preprocessor” which is a scripting programming language. Used mostly for websites on the server-side, it is a robust, cross-platform, extensible, programming language that powers 60% of the web. 60% is a huge number when there’s at least an infinite amount of websites.

While you don’t need PHP to create a website, PHP gives a programmer the ability to create dynamic websites that do more than just display static information. PHP gave way to websites with logins, displaying data from databases, or just showing random dynamic text. While that’s how PHP started, it now powers tools like Pagemend and other open-source software like WordPress.

The problem is that PHP generally runs on an Apache server. Not sure what that is? Exactly! Not many people have servers around so how are you supposed to start coding in PHP? Well, you could do it how I did it – go find cheap shared hosting. It’ll probably cost you $5 a month but that was a lot for me when I was a broke kid. All I had was a computer – not even a credit card yet.

Fortunately, there is a way to test PHP locally and get it running on any computer for free with XAMPP!

What Is XAMPP

XAMMP is a computer program tool for developing PHP web applications on Windows, Mac OS X, and Linux on your computer without needing a web server. XAMMP makes it easy to install a “local” web server on your computer with Apache, MySQL, and PHP so you can run and test PHP locally without having to upload to a server.

Computers don’t come with the required software to run PHP and dynamic website programming languages, so it gets hard to test PHP code – and that’s where XAMPP comes in. You can test any and all of your PHP and MySQL code right on localhost. One of my favorite benefits of this is that you can save a file and it automatically updates the file in your browser – no more uploading! It’s just an easy way for a web developer to test a website locally on their PC before uploading it to a web hosting environment.

Find Website Issues Before Your Customers Do

Peace-of-mind website scanning with results shown in plain English for those who don't speak nerd and have other things to do.

Scan My Website. Free!

Fortunately, XAMPP is free and open source so you can download and use it whenever and however you want.

Just head on over to ApacheFriends.org to grab the download.

How to Test PHP Locally

  1. The first step is to testing PHP locally is to go to the ApacheFriends.org website and download XAMPP. Apache is open-source that’s used to deliver web content, and XAMPP is a special release made available by Apache Friends, which is a non-profit.
  2. The next step is to run the .exe and install. it’s important to deactivate any antivirus software, as this can interfere with the installation.
  3. Once the installation is complete, the next step is to configure the installation settings in the XAMPP setup wizard, which should appear automatically. When it does, click on “Next” to access and configure the installation settings.
  4. When these settings have been configured, choose the software components. This can be accomplished by accessing the Select Components menu, which also makes it possible to exclude various individual components of the XAMPP bundle from the installation. For a full test of a local server, the recommendation is to install and use the standard setup and all of the available components. Once this series of selections have been completed, click on “Next” and proceed to the steps pertaining to the installation directory.
  5. The installation directory allows you to choose where the various XAMPP software packets will be installed. If you choose a standard setup, a folder with the name XAMPP will be created, and it will be located in the C drive under the designation “C:/“. Once you’ve chosen this location, click “Next” to access the “Welcome to XAMPP” screen and start the installation.
  6. When you initiate this step and start the installation process, the setup wizard will install the components you’ve selected and save them to your chosen directory. This process may take several minutes, but you can flow the process by watching the green loading bar in the center of the screen.
  7. The last step is to complete the installation. This can be done by clicking on “Finish” in the setup wizard. When the installation process is finished, click the corresponding check box that allows you to open the XAMPP Control Panel after the installation is completed.

Testing the XAMPP Installation

  1. Once the installation is finished, you can also verify the installation by creating a PHP test page, then saving the settings on your XAMPP’s localhost and accessing and retrieving them using your web browser.
  2. The first step to do this is to open the XAMPP directory by using the “Explorer” button in the Control Panel. Select the folder entitled “htdocs,” which will contain the stored file data for the web pages you wish to test on your XAMPP server. Store your projects in a new folder and create a separate name for it.
  3. The next step is to create a new PHP page by using the specified content in your editor and storing it as test.php in your test folder to create a PHP testing page.
    1. Try using this code if you’re not sure what the file should be:
      1. <?php
        phpinfo();
        ?>
  4. The final step in the testing process is to open your PHP page using “localhost/FOLDER-NAME/test.php”. Your browser should display a long table of PHP settings. If it doesn’t, something may be wrong with your configuration.
Find Website Issues Before Your Customers Do

Peace-of-mind website scanning with results shown in plain English for those who don't speak nerd and have other things to do.

Scan My Website. Free!

Author:
I've been making websites since I was a kid and now have over 20 years of experience building them for myself and my agency. I noticed patterns of problems that all business owners experience with their websites. Problems that most business owners don’t even know matter, let alone how to address. I built Pagemend to help people stay on top of their websites.

Leave a Reply

Enquire now

Give us a call or fill in the form below and we will contact you. We endeavor to answer all inquiries within 24 hours on business days.