pillarOfLight pillarOfLight - 1 year ago 181
PHP Question

Trying to debug phpunit unit test on cli using xdebug fails

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:


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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download