Disclaimer: That's another of those posts where my main goal is to register for my future reference and avoid spending lots of time "googling" to remember.
With some hope, this can somehow help someone else too!
For tests, I will use the PHPUnit library installed using Composer.
composer require phpunit/phpunit
We can create with the command:
PHP Code Coverage is a library that provides collection, processing, and rendering functionality for PHP code coverage information.
You can add this library as a local, per-project dependency to your project using Composer:
composer require phpunit/php-code-coverage
If you only need this library during development, for instance, to run your project's test suite, then you should add it as a development-time dependency:
composer require --dev phpunit/php-code-coverage
Xdebug is an extension for PHP and provides a range of features to improve the PHP development experience, one of them is to provide Code Coverage Analysis to show which parts of your code base are executed when running unit tests with PHPUnit.
It is necessaire to active Xdebug on your PHP. More details on Xdebug official documentation.
vendor\bin\phpunit --coverage-html < directory >
PHPUnit documentation is available here.