I'm using PHPStorm which is configured to use xDebug (I can debug via the web browser just fine)
I run the debugger in PHPStorm which has the idekey of 11854 and I'm trying to debug a unit test, and I've set the breakpoints properly
so I executed this command through the cli:
phpunit -d xdebug.profiler_enable=on -d xdebug.idekey=11854 --filter testFunction s_function/sFunctionTest.php
Nonetheless, it wouldn't debug at the breakpoint accordingly...
when I tried executing this in the test script:
error_log(ini_get('xdebug.profiler_enable'));
error_log(ini_get('xdebug.idekey'));
it would reveal that xdebug.profiler_enable is 0 and xdebug.idekey is just my username.
What did I do wrong and how can I get xdebug to work on phpunit through the cli
Xdebug cannot connect to PhpStorm This means that Xdebug tries to connect to the host and can't make the connection. To fix the issue, set xdebug. remote_connect_back=0 ( xdebug. discover_client_host=false for Xdebug 3) and make sure that xdebug.
Press F5 to start the debugger. Click the new XDebug Helper extension and click the Debug option. Finally, refresh the page in the browser to let VSCode react and start the debugging process.
Enable Xdebug logging by adding the following line into php. ini: xdebug. remote_log=/log_path/xdebug.
You are just setting arguments to phpunit, not to PHP. The following should do what you want:
php -d xdebug.profiler_enable=on -d xdebug.idekey=11854 `which phpunit` --filter testFunction s_function/sFunctionTest.php
The xdebug docs give a solution that looks simpler...
export XDEBUG_CONFIG="idekey=session_name"
php myscript.php
Once that variable is set, you can run your scripts from the command line as normal (for that SSH session) and PHP will use this configuration.
Also of note:
You can also configure the xdebug.remote_host, xdebug.remote_port, xdebug.remote_mode and xdebug.remote_handler in this same environment variable as long as you separate the values by a space
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With