I would like to use PHPUnit to create code coverage reports. I have tried a lot of installation setups found on the web. But nothing seems to work out.
I use the lat
It seems like you are missing the Xdebug extension. If you're using homebrew you can install it like:
brew install php70-xdebug
After that, don't forget to edit your php.ini file to enable the extension.
php -i | grep xdebug
After checking that xdebug is enabled you should be able to do code coverage
Update for anyone else stuck;
pecl install xdebug
it's worked for me. follow this step :
1.) install php7.x-dev, (x) is PHP version on your Linux server
sudo apt-get install php7.x-dev
2.) install Xdebug through PECL on Linux
sudo pecl install xdebug
3.) add the following php.ini file. (you can insert it on last line)
zend_extension="/wherever/you/put/it/xdebug.so"
Update for PHP 7.1
xdebug is essential for code lookup and coverage , so xdebug is must to be installed or enabled in test environment. xdebug in production environment is not suggestible, it will affect performance if you turned on
brew install php71-xdebug
As other developers answered, you need to install PHP Xdebug but I want to add new recommend for the developers who are using homestead by default have Xdebug (but it is off) and you can make it ON or OFF
If you want to make it on use below command in homestead
#for on :
xon
#for off:
xoff
Then check php -v
and you will see Xdebug in the detail box
If you run phpunit inside a vagrant box then you don't need to install xdebug in local and homestead comes with xdebug install automatically. only needs to link homestead xdebug.ini file
Here is the step that worked for me:
cd ~/homestead/REPLACE THIS WITH YOUR HOMESTEAD FOLDER IN LOCAL //
vagrant ssh
sudo ln -s /etc/php/7.2/fpm/conf.d/20-xdebug.ini /etc/php/7.2/cli/conf.d/
In the above command if your running 7.3
or 7.1
then replace it based on your php version