I\'ve tried running the following CLI command:
phpunit -d xdebug.profiler_enable=on XYZTestCase.php
but it just runs as normal. Can anyone
Did you try to :
restart your server
Call you script by adding -d xdebug.idekey=blacktie
phpunit -d xdebug.profiler_enable=on -d xdebug.idekey=blacktie XYZTestCase.php
Hope that help.
On Windows with phpStorm
Enter this into the command line:
set XDEBUG_CONFIG="idekey=PHPSTORM"
This will add an environment variable that phpStorm will lookout for.
The only thing I need to do in the terminal, while using VS code debugger (with WSL), is execute this command:
export XDEBUG_CONFIG="idekey=VSCODE"
after that I simply run my phpunit command as usual. i.e. phpunit ./tests/
and the debugger will stop on the first breakpoint I have set.
If the debugger pauses on unreachable code, you might want to toggle of "Everything" in the debugger pane under Breakpoints.
I got this info from https://tighten.co/blog/configure-vscode-to-debug-phpunit-tests-with-xdebug
:: EDIT ::
While the above worked on my local webserver. I got bit by this today as I tried to port my project to docker.
It turned out it will not work with this setting:
xdebug.remote_connect_back=1
But you need to set this instead:
xdebug.remote_host=172.17.0.1
xdebug.remote_connect_back=0
Note: I use 172.17.0.1 to refer to my host machine from inside the docker container because I am on linux, but if you are on a mac it's probably better to use:
xdebug.remote_host=docker.for.mac.host.internal
xdebug.remote_connect_back=0
or on windows:
xdebug.remote_host=host.docker.internal
xdebug.remote_connect_back=0
With docker it seems like I did not need to do export XDEBUG_CONFIG="idekey=VSCODE"
anymore either.