Laravel 5: PHPUnit and no code coverage driver available

前端 未结 8 606
深忆病人
深忆病人 2020-12-25 09:49

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

相关标签:
8条回答
  • 2020-12-25 09:54

    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

    0 讨论(0)
  • 2020-12-25 09:56

    Update for anyone else stuck;

    pecl install xdebug

    0 讨论(0)
  • 2020-12-25 09:58

    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"
    
    0 讨论(0)
  • 2020-12-25 10:06

    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

    0 讨论(0)
  • 2020-12-25 10:08

    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

    0 讨论(0)
  • 2020-12-25 10:12

    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

    0 讨论(0)
提交回复
热议问题