Adding Code Coverage

install in ubuntu

sudo apt-get install php-xdebug


No code coverage driver is available
-> dont forget to install php-xdebug

Install in intel mac

pecl install xdebug

Install in mac M1

file `which php` #mine is Mach-O 64-bit executable arm64
arch -arm64 pecl install xdebug
#cd /opt/homebrew/etc/php/8.1/conf.d/
#echo "xdebug.mode=debug" > xdebug.ini

To run it


XDEBUG_MODE=coverage php artisan test --coverage #pest

Uninstalling xdebug

arch -arm64 pecl uninstall xdebug

Excluding Framework files

    <coverage processUncoveredFiles="true">
            <directory suffix=".php">./app</directory>
            <directory suffix=".php">./app/Macros</directory>

To make a report to HTML

    <log type="coverage-html" target="./report" charset="UTF-8"
        yui="true" highlight="true"
        lowUpperBound="50" highLowerBound="80" />

Subscribe to You Live What You Learn

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]