I\'ve been struggling to get xdebug to work all day. I have tried a complete reinstall of homebrew, cleared out php and installed the newest version, reinstalled apache (fo
Each error has a different cause.
First of all, your sudo pecl install
is generally the right way of installing Xdebug, because, as you've found you can set the installation directory with pecl config-set
.
However, the pecl/pear version that you are running, is likely for an old version of PHP. Because PHP does change once in a while, the pecl tool needs to be updated too. For PHP 7.2, I run pecl version 1.10.9 (you can check with pecl -V
). I would think that the one you're running is quite a bit older. Generally you can update pear/pecl by using pear upgrade pear
, but you will likely run into an unwritable directory problem again.
Secondly, sudo make install
to fails because it is trying to write into an unwritable directory (/usr/lib/php/extensions/no-debug-non-zts-20180731/
). If you know what the right directory is (check with php -i | grep extensions
), you can just copy it into that directory yourself. After the make
stage, there should be a xdebug.so
in the modules
directory within the Xdebug source tree.
The "official" way to solve the latter problem is to use the --with-php-config
option to Xdebug's ./configure
line, where you can specify the one that you want to use for Xdebug with something like: ./configure --with-php-config=/usr/local/opt/php@7.2/bin/php-config
(but check the paths, as I don't have a Mac set up here). This should then pick up the right extensions directory, and sudo make install
should work.