Skip to content
Advertisement

Error to Install xdebug on Mac OS with php 8

I just want to do phpunit --coveragefor my project first I got this error:

PHPUnit 9.5.0 by Sebastian Bergmann and contributors.

Warning:       No code coverage driver available

I just check my php to make sure I have xdebug via php -v

PHP 8.0.0 (cli) (built: Nov 30 2020 13:51:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies

seems I do not have it then I just install it via pecl install xdebug Homebrew I got this error at the end of installation:

........

Build process completed successfully
Installing '/usr/local/Cellar/php/8.0.0_1/pecl/20200930/xdebug.so'

Warning: mkdir(): File exists in System.php on line 294

Warning: mkdir(): File exists in /usr/local/Cellar/php/8.0.0_1/share/php/pear/System.php on line 294
ERROR: failed to mkdir /usr/local/Cellar/php/8.0.0_1/pecl/20200930

Advertisement

Answer

You can step by step debug this problem with starting to check what it is inside the /usr/local/Cellar/php/8.0.0_1 folder running

$ cd /usr/local/Cellar/php/8.0.0_1
$ la -la

I tend to say that there is a pecl symlink already existing which is why pecl cannot create a folder there.

Then you should check where pecl is installed by running which pecl which ideally gives you /usr/local/bin/pecl which should point to somewhere /usr/local/Cellar/php/8.0.0_1/bin/pecl.

If that is the case you can remove the /usr/local/Cellar/php/8.0.0_1/pecl symlink with

$ rm /usr/local/Cellar/php/8.0.0_1/pecl

and try to reinstall xdebug.

Now fixing the image not found issue

This comes from an incorrect configuration during the xdebug installation.

First, check what the path to your php.ini file is by running ˋphp —-iniˋ. Then open the file and check the First line if there is your xdebug Extension loaded. If yes, remove it there. Then add a file xdebug.conf in the conf.d folder and add the following:

;XDebug
zend_extension="/usr/local/Cellar/php/8.0.0/pecl/CHANGEME/xdebug.so"
xdebug.remote_autostart=1
xdebug.remote_port=9000
xdebug.remote_enable=1
xdebug.profiler_enable=1
xdebug.profiler_output_dir="/tmp"

Please check that you have the correct path to your xdebug.so file and that the output dir exists.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement