ref: e107b46712f6bd52301961e3a47580b0a8cbb0e6 www.tuxed.net/posts/phpunit_xdebug.md -rw-r--r-- 1002 bytes
e107b467François Kooman add php-jwt 3 years ago

#title: PHPUnit and Xdebug published: 2017-01-12

Having the Xdebug PHP extension always loaded slows down Composer and Phan.

But I do want to have Xdebug enabled for generating code coverage reports using PHPUnit.

It took me some time to figure this out, and it is not so hard.

First step: install the Xdebug extension, on Fedora:

$ sudo dnf -y install php-pecl-xdebug

Edit the file /etc/php.d/15-xdebug.ini to disable loading the extension:


Now, to enable this extension just for running PHPUnit:

$ php -dextension=/usr/lib64/php/modules/xdebug.so /usr/bin/phpunit \
    --coverage-html coverage

To automate this, add the following alias to your $HOME/.bashrc:

alias phpunit="/usr/bin/php -dextension=/usr/lib64/php/modules/xdebug.so /usr/bin/phpunit"

It was surprisingly hard to figure this out, hope it helps someone!