Can't run Codeception test and Xdebug at the same time


I'm unable to properly run Codeception tests that make requests to my PHP app and trigger Xdebug break points as a result of these requests. I can get Xdebug to stop on the break points but no Codeception results are returned to the PHPStorm interface.

In Detail

I'm running my PHP app in a VirtualBox VM. I've setup a remote PHP interpreter for the VM. XDebug works fine when I make HTTP requests to my app from my browser. XDebug also works fine if I ssh into the VM and make a cURL request to my app. Debugging a codeception test also works fine with the remote PHP interpreter.

The problem arises when I attempt to run Codeception tests from PHPStorm. PHPStorm executes the test via the remote interpreter, the test makes HTTP calls to my PHP app (which are essentially calls to the local server because Codeception and PHP app are being executed in the VM), PHPStorm pauses at break point, request completes but no test results are returned to PHPStorm.

My settings are as follows:

XDebug on VM

xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_host = //IP address of my host machine.
xdebug.remote_connect_back = 0

XDebug config

PHP server config

Remote interpreter config

Codeception run config

Debug window when running Codeception test from PHPStorm:

  • Unconfigured 'codeception.php' tab pops up when I haven't configured that debug. I presume this is the PHPStorm helper file that gets uploaded to the VM.
  • Unconfigured 'index.php' tab pops up which shows the details when stopping on a break point.
  • No break points ever show in the config I setup called 'Xdebug - VM' - this is the one I would expect the break points to show in.

Error message that pops up everytime:

Further to this, when I'm 'listening for new connections', each debug session opens up a new debugging tab:

Any help would be appreciated.

Cheers, Rob.

Comment actions Permalink

Have you setup PHP_IDE_CONFIG and XDEBUG_CONFIG in the env vars of the codeception run task in phpstorm?


Presumably you have these configured for debugging from the command line when you ssh in to the vm.

Comment actions Permalink

I have tried using those env vars before but it just hangs as if it has stopped at a break point but PHPStorm doesn't show it and I also can't continue. I don't think I would need to set XDEBUG_CONFIG as I have this stuff setup in the php.ini which both HTTPD and CLI use. Thanks for the help.

Comment actions Permalink

I gave up on getting this working properly and instead sent the XDEBUG_SESSION cookie with each API request made by Codeception tests - works fine.


Please sign in to leave a comment.