How To Generate Code Coverage on Laravel Homestead

profile picture

How To Generate Code Coverage on Laravel Homestead

TDD is cool right ? PHPUnit implementation in Laravel is so great that it makes TDD even cooler.

When building your application you may wonder : did I test everything ?? And how can I make sure that everything is tested ?

That's where PHPUnit Code Coverage is fantastic.

In Laravel Homestead however it is not that easy to setup. Running phpunit --coverage-html testReport/ will probably give you an error at first. What you need is to install XDebug !

Let's do that :

sudo apt-get update && sudo apt-get upgrade && sudo apt-get install php-xdebug

Now edit Xdebug config file...

sudo nano /etc/php/7.1/fpm/conf.d/20-xdebug.ini

And make sure you have this setup :

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back = 1
xdebug.remote_port = 9000
xdebug.max_nesting_level = 250

Finally, restart and activate !

sudo service php7.0-fpm restart

sudo phpenmod -s cli xdebug

Now everything should be good ;)

about me

profile picture

I consider myself as an IT Business Artisan. Or Consultant CTO. I'm a self-taught Web Developper, coach and teacher. My main work is helping and guiding digital startups.

more about me

follow me

newsletter

A weekly email with the latests articles

support my work

Start trading on binance
  • BTC

    BTC

    bc1qgw9a8hyqqwvcls9ln7vhql4mad0qkveutr2td7

  • ETH

    ETH

    0x3A720717Da03dB6f3c4a4Ff08BC64100205A79d0

2025 © My Dynamic Production SRL All rights Reserved.