This article is showing step by step how to set up Xdebug in PHPStorm.
Content:
- How to install Xdebug on Windows
- How to set up Xdebug on PHPStorm
- How to run tests using Xdebug in PHPStorm
How to set up Xdebug on PHPStorm
- Open PHPStorm and go to File -> Settings -> Languages & Frameworks -> PHP -> Debug.
- Click Start on ‘Enable listening for PHP Debug Connections’.
- Make sure that the Debug port under Xdebug is set to the one you have specified in your php.ini file (e.g xdebug.remote_port=9000 )
- Click Apply
- In the right side of the screen, click on the drop-down and select Edit configurations
- Click the + sign on the left side of the screen.
- Configure your new Configuration:
- Give it a custom name.
- Select Directory as the Test Scope.
- Set the path to the /tests directory.
- Tick the box to Use alternative configuration file.
- Set the path to your configuration file, phpunit.xml in project’s case.
- Click on the settings button, pointed out with a red line in the picture below.
-
- Once you clicked that button, another dialog box will open. There, you set up how to load the test framework. For this project, I use the Composer autoloader. The path to the autoloader script is C:\Your\Project\vendor\autoload.php. Click Apply and OK then the same in the other dialog box.
How to run tests using Xdebug in PHPStorm
-
- Test that it works by running your tests. Click the green play button in the top right. If your tests run fine, you should get a similar output:
-
- Test that it works by running your tests. Click the green play button in the top right. If your tests run fine, you should get a similar output:
I prefer to use xDebug with Codelobster IDE – http://www.codelobster.com