Set up Xdebug in PHPSTORM

HOW TO: Set up Xdebug in PHPStorm

This article is showing step by step how to set up Xdebug in PHPStorm.


  1. How to install Xdebug on Windows
  2. How to set up Xdebug on PHPStorm
  3. How to run tests using Xdebug in PHPStorm

HOW TO: install PHP 7.2 on Windows

How to set up Xdebug on PHPStorm

  1. Open PHPStorm and go to File -> Settings -> Languages & Frameworks -> PHP -> Debug.
    1. Click Start on ‘Enable listening for PHP Debug Connections’.
    2. 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 )
    3. Click Apply
    4. PHPStorm Settings
      PHPStorm Settings
  2. In the right side of the screen, click on the drop-down and select Edit configurations
    1. Edit configurations
      Edit configurations
  3. Click the + sign on the left side of the screen.
    1. Add PHPUnit configuration
      Add PHPUnit configuration
  4. Configure your new Configuration:
    1. Give it a custom name.
    2. Select Directory as the Test Scope.
    3. Set the path to the /tests directory.
    4. Tick the box to Use alternative configuration file.
    5. Set the path to your configuration file, phpunit.xml in project’s case.
    6. Click on the settings button, pointed out with a red line in the picture below.
      1. PHPUnit configuration
        PHPUnit configuration


    7. 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.
      1. Set autoloader
        Set autoloader

How to run tests using Xdebug in PHPStorm

    1. 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:
      1. Run the tests
        Run the tests


One thought on “HOW TO: Set up Xdebug in PHPStorm

Leave a Reply

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