Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't I step through PHPunit tests with XDebug when I run them from the command line?

PHP, XDebug, and my IDE (PhpStorm) are all configured properly. PhpStorm is listening, and it's picking up the debug session, but it never hits the breakpoint in my unit test class and I'm unable to step through it. The entire test runs.

Anyone have any ideas?

like image 881
sluther Avatar asked Oct 27 '25 16:10

sluther


1 Answers

I can step into PHPUnit tests without a problem using XDebug. However, I did notice that it sometimes seems to skip certain statements (such as simple assignment to variables in a function without anything else), so spread some breakpoints around.

Make sure you've set up path mapping properly, with the correct version of the library mapped over.

If you're using XDebug from the command-line, you have to set certain environment variables - see here and here.

In my case, the following environment variables needed to be set in the remote box and run from the remote box. 10.0.2.2 works OK for Virtualbox VMs - basically you need to point to your local machine.

export XDEBUG_CONFIG="idekey=PHPSTORM remote_host=10.0.2.2 remote_port=9000"
export PHP_IDE_CONFIG="serverName=[yourservernamehere]"

enter image description here

like image 98
Ben Creasy Avatar answered Oct 30 '25 07:10

Ben Creasy