0

I am trying to generate PHPUnit's code coverage report but get this error: No code coverage driver is available

I am on Mac and when I run php -v at the terminal I get this:

PHP 7.3.11 (cli) (built: Jul  5 2020 03:23:39) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.11, Copyright (c) 1998-2018 Zend Technologies

This SO answer told me to install XDebug with Homebrew, but that fails as Homebrew can't find a matching formula (for my version of php).

This answer on SO told me to install/activate XDebug or zend-debugger. To install XDebug, their website tells me to run pecl install xdebug, which has the error ERROR: failed to mkdir /usr/lib/php/pear/docs/xdebug/contrib (same error if I do sudo pecl install xdebug). If I try and create the folder manually, I get the error mkdir: pear: Operation not permitted.

Any help is appreciated.

Alan P.
  • 2,898
  • 6
  • 28
  • 52
  • Just a wild guess. Maybe pecl is still linked to an old version. You can check where the symlink points to with `ls -ahl /usr/local/bin/pecl`. In your case this should be something like `../Cellar/php/7.3.11/bin/pecl` – Philip Weinke Jul 22 '20 at 10:00
  • That command returns this path: `/usr/local/bin/pecl` – Alan P. Jul 22 '20 at 18:30
  • Okay. I guess you're using the php version that came with OSX. I don't know if I ever had this version running with XDebug. You might want to install php with brew. So if you want to stay with 7.3, run `brew install php@7.3` and after that try `pecl install xdebug` again. – Philip Weinke Jul 23 '20 at 06:09
  • I do have PHP installed with brew (v7.0.33, and this is the one apache is using as that is what `phpinfo()` reports; it does not mention xdebug). The PHP from the command line it is 7.3.11 from /usr/bin/php – Alan P. Jul 23 '20 at 22:15
  • I read another answer (https://stackoverflow.com/questions/51484747/failed-to-install-php-extention-with-pecl-on-mac-error-tips-fail-to-mkdir-usr) that said it was Mac's System Integrity Protection that was preventing the install. I disabled it and tried again, but still no luck (even with sudo). – Alan P. Jul 23 '20 at 22:39
  • I changed my $PATH variable so it points to the same PHP as apache (v7.0.33). Now `pecl install xdebug` tells me it needs at least PHP v7.1.0. The lowest version of PHP on Homebrew is v7.2 and I can't do that upgrade yet, so this will have to wait. Thanks for your help @PhilipWeinke – Alan P. Jul 23 '20 at 22:58
  • Maybe there is a way to install PHP v7.1.0 from homebrew: https://stackoverflow.com/questions/60128044/error-while-installing-php-7-1-for-mac-with-homebrew – Alan P. Jul 23 '20 at 23:06
  • I think PHP 7.1 is not officially supported by brew anymore, but the answer in your link may do the trick. You can also have multiple php versions installed with brew and switch between them. [Here](https://getgrav.org/blog/macos-catalina-apache-multiple-php-versions) is a tutorial on that topic. – Philip Weinke Jul 24 '20 at 06:59
  • Link php7.3 by brew unlink php && brew link --overwrite --force php@7.3 an then pecl install xdebug resolved my issue – Nidhin Jul 12 '21 at 10:04

0 Answers0