Windows Local PHP Development Server

November 5, 2021 • • Published By • 3 minute read

There are many open source packages out there for developing locally with PHP on Windows. Did you know that PHP itself comes with its own local development server?! Let’s learn how to use it!

Table of Contents

Why Install PHP Locally?

You can always make changes directly to a production app or website, but you run the risk of making a mistake and causing issues! Installing and serving PHP locally allows you to safely develop and test PHP apps and websites prior to deploying to production.

Open Source Windows PHP Server Packages

Here are some examples of popular open source Windows PHP server packages. You can easily install one of these and have everything you need to develop and serve PHP locally. Follow the package’s instructions on how to install and use it.

  • XAMPP is a completely free, easy to install Apache distribution containing MariaDB, PHP, and Perl. The XAMPP open source package has been set up to be incredibly easy to install and to use.
  • WAMP is a Windows web development environment. It allows you to create web applications with Apache2, PHP and a MySQL database.
  • EasyPHP is a complete and ready-to-use PHP development environment on Windows including the web server Apache, the SQL Server MySQL and others development tools.

Local PHP Installation

Instead of using one of the packages above, you can also download and install PHP locally.

  1. Download PHP using one of the provided Windows downloads.
  2. Extract the files.
    • You can put it anywhere but a popular location is on your C drive.
  3. Configure php.ini.
    • Copy the provided php.ini-development to a new file called php.ini.
    • Enable any extensions you need.
  4. Update path environment variable.
    • In the Windows search bar, search for environment and select “Edit system environment variables”.
    • Select the Advanced tab and select Environment Variables.
    • Under System Variables, select New and add C:\php as the path (adjust the path if you installed PHP in a different location).

If you had any command windows open prior to updating the environment path, close and reopen them so the change is applied.

Local PHP Server

To develop and test PHP locally, you need to run the local PHP server from the parent folder where the PHP files exist.

In a command window, navigate to the folder where your PHP files are located. Then run the following:

php -S localhost:8000

In the browser, visit localhost:8000 and you should see your PHP files working!

Related Articles
About the Author

Front End Developer

https://nightwolf.dev