How to debug with PhpStorm, Valet+ and Xdebug

  • Post author:
  • Post category:Xdebug

I’m using Valet+ as my development environment on MacOS. It is easy to set up and it works fine for me but I did have problems with Xdebug. Xdebug was enabled by default, I created a` breakpoint in PhpStorm but Xdebug did not stop on my breakpoint. So what was the problem?

It happened because PhpStorm mapped incorrect file to debug. Check the screenshot.

Incorrect file to debug in Xdebug

It wanted to debug some  codeception/codeception/tests/data/rest/server.php file. But it’s wrong.

You need to ignore all requests with incorrect project or file to debug. Just click Ignore.

Then you need to go to PhpStorm Preferences -> Languages & Frameworks -> PHP -> and specify include path to the correct Valet+ folder.

Specify include path in PhpStorm

The correct folder name is <your_home_directory>/.composer/vendor/weprovide/valet-plus 

Add correct valetplus folder to include path

After that go to your browser and refresh your page you want to debug with enabled Xdebug. Now in your PhpStorm you will get Xdebug popup with correct file to debug: <your_home_directory>/.composer/vendor/weprovide/valet-plus/server.phpClick Accept now.

Correct file to debug

Now Xdebug will stop your you breakpoint. Congratulations!

Xdebug stops on breakpoint in PhpStorm