Install Xdebug on Windows

HOW TO: Install XDEBUG on Windows

This article will show you step by step how to install and use Xdebug on Windows.

Contents:

  1. Resources
  2. What is Xdebug
  3. Why use Xdebug
  4. How to install Xdebug
  5. How to set up Xdebug on PHPStorm
  6. How to run tests using Xdebug

Resources:

Xdebug and You: Why You Should be Using a Real Debugger

Xdebug Docs

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.

HOW TO: install PHP 7.2 on Windows

  1. Go here and install Xdebug:
                1.  Run the following command in a terminal:
                  php -i
                  How to install XDEBUG - php -i
                  How to install XDEBUG – php -i

                   

                2.  Copy the output of that command and paste it in the Xdebug Wizard. Then click Analyze my phpinfo() output.

                  Xdebug Wizard
                  Xdebug Wizard
                3.  Once analyzed, the result will tell if you have Xdebug installed or not, and which .dll file to download.
                  Xdebug result
                  Xdebug result

                   

                4.  Download the specified file from the step before. For me is: php_xdebug-2.6.0-7.2-vc15-nts-x86_64.dll
                5.  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
                6. Copy file to ext directory

                  Top 3 free coding editors

                7. 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. 
                8.  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
                  Add extension in php.ini
                9.  Check if Xdebug has been installed by running the following command in a terminal:
                  • php -v

                   

                  Check Xdebug is installed
                  Check Xdebug is installed

                  The line that says ‘with Xdebug v2.7.0alpha1’ confirms that it has been installed correctly.

                HOW TO: Set up Xdebug in PHPStorm

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.