I have a laravel project and I tried to run phpunit
to give me a coverage report. I ran the command vendor/bin/phpunit --coverage-html storage/test-output-data/coverage-html
and it gave the output:
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
Error: No code coverage driver is available
I tried to resolve this situation by doing a sudo pecl install pcov
, but running the phpunit still gave the same error above.
I noticed that I have the file /usr/lib/php/20170718/pcov.so
. So I added the line extension=/usr/lib/php/20170718/pcov.so
to my /etc/php/7.4/cli/php.ini
file. But when I type php -v
, I get this error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/pcov.so' (tried: /usr/lib/php/20170718/pcov.so (/usr/lib/php/20170718/pcov.so: undefined symbol: _zval_ptr_dtor), /usr/lib/php/20190902//usr/lib/php/20170718/pcov.so.so (/usr/lib/php/20190902//usr/lib/php/20170718/pcov.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.11 (cli) (built: Oct 10 2020 19:44:50) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.11, Copyright (c), by Zend Technologies
I also have a folder called /usr/lib/php/20190902
but it does not have a pcov.so
file.
I also tried doing a sudo pecl install xdebug
, but I run into similar errors as above where phpunit says there's no driver and typing php -v
says some global variable is missing similar to the pcov issue.
What am I doing wrong?