How to Install XDebug on a new Mac (including Mojave)

Disable System Integrity Protection

  • Restart, hold down command + r to boot to recovery
  • Launch Terminal
$ csrutil disable

Install PEAR and PECL

Update PECL

$ sudo pecl channel-update pecl.php.net

Install Homebrew

And upgrade definitions

$ brew update

Install autoconf

$ brew install autoconf

Install automake

$ brew install automake

Make php.ini file

Find out which php.ini file is being used

$ php -i | grep php.ini
Loaded Configuration File => /etc/php.ini

Create a php.ini file if needed

$ sudo cp /private/etc/php.ini.default /private/etc/php.ini

Set php_ini in PECL

Be sure to use use the correct reference to your php.ini file. If you created one, use the path to the new php.ini file.

sudo pecl config-set php_ini /etc/php.ini

Install XDebug

$ sudo pecl install xdebug

Append to php.ini

  • # get path to xdebug.so from the xdebug installer, if it didn’t already add it.
$ sudo nano /private/etc/php.ini

Append the following:

zend_extension=/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

Restart Apache

$ sudo apachectl restart

Verify

$ php -i | grep "Xdebug"

Enable System Integrity Protection

  • Restart, hold down command + r to boot to recovery
  • Launch Terminal
$ csrutil enable

Leave a Reply

Your email address will not be published. Required fields are marked *