This article will show you step by step how to install and use Xdebug on Windows.
Contents:
- Resources
- What is Xdebug
- Why use Xdebug
- How to install Xdebug
- How to set up Xdebug on PHPStorm
- How to run tests using Xdebug
Resources:
Xdebug and You: Why You Should be Using a Real Debugger
Official Xdebug installation guide from JetBrains (really good)
What is Xdebug?
Xdebug is an extension for PHP to assist with debugging and development.
Why use Xdebug?
Makes development easier by allowing the developer to debug his code in a simple and quick way.
How to install Xdebug
In this tutorial, we will be installing Xdebug on Windows 10, the steps are similar for any Windows version. You must have PHP installed on your system.
- Go here and install Xdebug:
-
-
-
-
-
-
- Run the following command in a terminal:
php -i
How to install XDEBUG – php -i - Copy the output of that command and paste it in the Xdebug Wizard. Then click Analyze my phpinfo() output.
Xdebug Wizard - Once analyzed, the result will tell if you have Xdebug installed or not, and which .dll file to download.
Xdebug result - Download the specified file from the step before. For me is: php_xdebug-2.6.0-7.2-vc15-nts-x86_64.dll
- Move the downloaded file to the /ext folder. This is the folder where PHP keeps all of its extensions and can be found under the folder where you have installed PHP. On mine, it is located in C:\PHP\ext.
Copy file to ext directory
- Run the following command in a terminal:
- Open php.ini file in an editor like Notepad, Notepad++ or Visual Code. This file is located within the folder where you installed PHP, C:\PHP\php.ini for me.
- At the end of this file, add the following lines:
-
zend_extension= "C:\PHP\ext\php_xdebug-2.7.0alpha1-7.2-vc15-nts-x86_64.dll" // full path to your file xdebug.remote_enable=1 xdebug.remote_host="localhost" xdebug.remote_port=9000
Add extension in php.ini -
- Check if Xdebug has been installed by running the following command in a terminal:
-
php -v
Check Xdebug is installed The line that says ‘with Xdebug v2.7.0alpha1’ confirms that it has been installed correctly.
-
-
-
-
-
-
-
Where the instructions say
“At the end of this file, add the following lines:”
zend_extension= “C:\PHP\ext\php_xdebug-2.7.0alpha1-7.2-vc15-nts-x86_64.dll” // full path to your file
xdebug.remote_enable=1
xdebug.remote_host=”localhost”
xdebug.remote_port=9000
note that you need to substitute the name of the dll you’ve actually downloaded. You also need to remove the comment “// full path to your file”!
I recommend to try xDebug with Codelobster IDE – http://www.codelobster.com