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

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.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)