--- title: PHPUnit and Xdebug published: 2017-01-12 --- Having the [Xdebug](https://xdebug.org/) PHP extension always loaded slows down [Composer](https://getcomposer.org/) and [Phan](https://github.com/etsy/phan). But I do want to have Xdebug enabled for generating code coverage reports using [PHPUnit](https://phpunit.de/). 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: ;zend_extension=xdebug.so 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!