beyondcode / herd-community

77 stars 1 forks source link

[Bug]: No code coverage driver available #856

Closed joshembling closed 1 month ago

joshembling commented 2 months ago

Platform

macOS

Operating system version

macOS Sonoma 14.4

System architecture

ARM64 (M1, M2, etc)

Herd Version

1.8.0

PHP Version

8.2.20

Bug description

I have a Herd Pro subscription that comes with Xdebug out of the box.

When running herd debug artisan test --coverage, I'm always met with the following output No code coverage driver available

My php.ini file looks like this:

curl.cainfo=/Users/me/Library/Application Support/Herd/config/php/cacert.pem
openssl.cafile=/Users/me/Library/Application Support/Herd/config/php/cacert.pem
pcre.jit=0

memory_limit=128M
upload_max_filesize=20M

/Applications/Herd.app/Contents/Resources/xdebug/xdebug-82-arm64.so
xdebug.mode=develop,coverage,debug
xdebug.start_with_request=yes
xdebug.start_upon_error=yes
auto_prepend_file=/Applications/Herd.app/Contents/Resources/valet/dump-loader.php

And my debug.ini file:

zend_extension=/Applications/Herd.app/Contents/Resources/xdebug/xdebug-82-arm64.so
xdebug.mode=debug,develop,coverage
xdebug.start_with_request=yes
xdebug.start_upon_error=yes

Steps to reproduce

  1. Run herd debug artisan test --coverage with the above settings in php.ini and debug.ini
  2. View the output as herd debug artisan test --coverage

Relevant log output

No response

joshembling commented 1 month ago

Should say I got this to work by doing the following:

  1. brew install php - even though PHP comes out of the box with Herd, it's necessary for the next step
  2. pecl install xdebug
  3. Once xdebug is installed, you'll see something like the following output:
    Build process completed successfully
    Installing '/opt/homebrew/Cellar/php/8.3.8/pecl/20230831/xdebug.so'
    install ok: channel://pecl.php.net/xdebug-3.3.2
    Extension xdebug enabled in php.ini
  4. Grab the installed path
  5. In taskbar, Herd > Show configuration files
  6. Open your php version folder
  7. Open php.ini
  8. Add the following lines if they do not exist
    [xdebug]
    zend_extension="/opt/homebrew/Cellar/php/8.3.8/pecl/20230831/xdebug.so" <---- double check this
    xdebug.mode=develop,debug,coverage
  9. Ensure the extension matches the path of your xdebug install

Hope this helps someone!

mpociot commented 1 month ago

You can also use the herd coverage command :)