
Setting Up a Windows PHP Development Environment

Setting Up a Windows PHP Development Environment
Setting up a local development environment for PHP on Windows has proven to be tricky if you're using an existing web-server package such as XAMPP or WAMP.
For my own personal configuration I use a combination of the following:
- NGINX
- A high-availability web server with integrated load-balancing features.
- PHP 7.2
- Server-sided scripting language interpreter.
- MariaDB
- Database server.
Tools
Local PHP development on Windows (10+) is best suited to an IDE like Visual Studio Code. It's free, open-source, and has great out-of-the-box support for PHP, with even better and community supported extensions for the language.
Extensions
Next you are going to want to install some extensions for Visual Studio Code. I recommend installing these for PHP syntax highlighting, linting, and debugging.
Debugging PHP on Windows (10+) works best with the following extensions for both PHP, and Visual Studio Code.
You can get the extensions from the following links:
- PHP Debug - felixfbecker.php-debug
- Enables breakpoint debugging with the XDebug PHP extension.
- PHP IntelliSense - felixfbecker.php-intellisense
- Enables for syntax and parsing of symbols, so that symbols can be searched and found across a codebase.
- phpcs - ikappas.phpcs
- php cs fixer - junstyle.php-cs-fixer
- PHP Symbols - linyang95.php-symbols
- Debugging symbols that are used by the PHP interpreter.
PHP
XDebug
I strongly recommend using XDebug, as Visual Studio Code can support breakpoint debugging through the usage of an extension that is available here.
Create a basic script with the following code.
Navigate to the page, and make sure that the script executes.
Copy the entire page contents and then paste it into this useful tool. The page will then inform you of which version of XDebug you should use for your installation of PHP.
Next, place the downloaded DLL into the following directory.
Change your php.ini configuration file to reflect the following.
You will likely also want to change the following parameter.
Visual Studio Code
You will likely want to make use of this configuration for your launch.json file. The following configuration gives you three debugging profiles.
launch.json
Environment
After installing your integrated development environment (IDE), and additional extensions to go with them, you will want to configure them using the following environment and configuration variables.
Variables
Several of the recommended PHP extensions make use of the PHP command-line for linting, code inspection, and syntax highlighting. Their default behaviour is to make use of the PHP client that is available from the path environment variable.
XDebug
You will want to place the following parameters at the end of your *.ini based configuration file for PHP.
These parameters ensure that you have XDEBUG configured, enabled, and listening for incoming debugger connections from Visual Studio Code.