尝试使用xdebug在cli上调试phpunit单元测试失败

pil*_*ght 6 php debugging phpunit xdebug phpstorm

我正在使用配置为使用xDebug的PHPStorm(我可以通过Web浏览器调试就好了)

我在PHPStorm中运行调试器,它具有11854的idekey,我正在尝试调试单元测试,并且我已正确设置断点

所以我通过cli执行了这个命令:

phpunit -d xdebug.profiler_enable=on -d xdebug.idekey=11854 --filter testFunction s_function/sFunctionTest.php
Run Code Online (Sandbox Code Playgroud)

尽管如此,它不会相应地在断点处进行调试......

当我在测试脚本中尝试执行此操作时:

error_log(ini_get('xdebug.profiler_enable'));
error_log(ini_get('xdebug.idekey'));
Run Code Online (Sandbox Code Playgroud)

它会显示xdebug.profiler_enable为0而xdebug.idekey只是我的用户名.

我做错了什么以及如何让xdebug通过cli在phpunit上工作

Der*_*ick 7

你只是设置phpunit的参数,而不是PHP.以下应该做你想要的:

php -d xdebug.profiler_enable=on -d xdebug.idekey=11854 `which phpunit` --filter testFunction s_function/sFunctionTest.php
Run Code Online (Sandbox Code Playgroud)