How can I get XDebug to run with PHPUnit on the CLI?

后端 未结 9 1978
时光取名叫无心
时光取名叫无心 2020-12-23 11:01

I\'ve tried running the following CLI command:

phpunit -d xdebug.profiler_enable=on XYZTestCase.php

but it just runs as normal. Can anyone

9条回答
  •  温柔的废话
    2020-12-23 11:33

    The xdebug.profiler_enable setting can't be changed at runtime but only at the start of script.

    Running phpunit -d foo=bar will just lead to phpunit calling ini_set("foo", "bar"); and that doesn't work since the value can't change at runtime.

    See: xdebug.profiler_enable

    Enables Xdebug's profiler which creates files in the profile output directory. Those files can be read by KCacheGrind to visualize your data. This setting can not be set in your script with ini_set(). If you want to selectively enable the profiler, please set xdebug.profiler_enable_trigger to 1 instead of using this setting.

    Solution:

    php -d xdebug.profiler_enable=on /usr/bin/phpunit XYZTestCase.php
    

    By applying the setting directly to the PHP runtime and not phpunit it will be set before the script starts and should work.

提交回复
热议问题