blob: 2b37c09643eb0e1b8c49e51b9c65c819c23ac051 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
---
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!
|