You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Spawning a second PHP process breaks the debugger #231
I've determined the root cause of #154 and produced a tiny reproducible example. It's not related to PHPUnit, it's caused by a call to system() which spawns a second PHP process and causes the VS Code debugger to malfunction.
Running the test case below will cause the debugger to get "stuck", with two requests appearing in the call stack panel and nothing else functional apart from the Stop button.
I observe the same behaviour when running unit tests with atoum. This framework runs a master process, creating a process for each test method. Therefore I got at least 2 PHP processes running. It seems that sometimes I can debug, but in most of my attempts, I forced to stop the debugger or the unit tests currently being debugged.
I also observe the same when I run my main project. This is a web application, and most of the time there are 2 nearly concurrent calls to the LAMP server. In this case too, a debug session freezes all requests, but if I try 2 or 3 times, the debug session runs correctly.
This also worked for me, adding a second configuration listening on 8000 and then:
'php -d xdebug.remote_port=8000 "vendor/bin/phpunit" "anyphpunitargument"'
Activity
johnbillion commentedon Jan 24, 2018
Oh, I guess this might be a duplicate of #164.
tdchien commentedon Feb 27, 2018
I'm same too. Finding a way for this
esther-86 commentedon Mar 10, 2018
I'm posting my answer to what I did to be able to debug my test code. If you can launch the second php with a different remote port, it might solve your problem.
https://stackoverflow.com/questions/49148551/how-can-i-get-xdebug-to-run-with-phpunit-on-the-cli-in-windows-using-vscode/49207236#49207236
btry commentedon May 1, 2018
Hi
I observe the same behaviour when running unit tests with atoum. This framework runs a master process, creating a process for each test method. Therefore I got at least 2 PHP processes running. It seems that sometimes I can debug, but in most of my attempts, I forced to stop the debugger or the unit tests currently being debugged.
I also observe the same when I run my main project. This is a web application, and most of the time there are 2 nearly concurrent calls to the LAMP server. In this case too, a debug session freezes all requests, but if I try 2 or 3 times, the debug session runs correctly.
yuvanathan commentedon May 16, 2018
This worked. I added php_value xdebug.remote_port 9001 in 2nd site's directory .htaccess.
jonathanjfshaw commentedon Jul 18, 2018
This also worked for me, adding a second configuration listening on 8000 and then:
'php -d xdebug.remote_port=8000 "vendor/bin/phpunit" "anyphpunitargument"'
You can run both configurations more easily if you use a compound configuration:
https://code.visualstudio.com/docs/editor/debugging#_multitarget-debugging
I use Lando as my development environment, which makes this solution a bit easier to implement, and I added it to their docs:
lando/lando#1107
zobo commentedon Jan 29, 2022
Old issue. The handling of parallel connections has been reworked a lot in this time. Closing, please reopen with latest log if issue persists.