Install PHP 7.3 + xdebug on MacOS Mojave (with homebrew)

First, you need to have homebrew installed, if you don’t have it please go to https://brew.sh/ and follow the installation steps.

Remove any old version of php:

brew list | grep php | awk '{ print "brew uninstall --force "$1}' | bash

To be sure, manually remove the php cellar folder:

rm -rf /usr/local/Cellar/php

Then clean any php tap (extra repo):

brew untap homebrew/php

Cleanup and Update your brew:

brew cleanup
brew update

Install the latest version of php:

brew install php

Clean up old xdebug:

pecl uninstall xdebug

Install the latest version of xdebug-beta (The xdebug is not compatible with 7.3 so you need to use the xdebug-beta):

pecl install xdebug-beta

The last step, edit the  /usr/local/etc/php/7.3/php.ini and add these lines at the bottom of this file:

zend_extension=xdebug.so
[XDebug]
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000

8 thoughts on “Install PHP 7.3 + xdebug on MacOS Mojave (with homebrew)”

  1. Your instructions worked to a t for me..almost.

    I needed to run full path to pecl:

    /usr/local/bin/pecl install xdebug

    Took a while to get to that for lesser folks like me that simply follow along blindly.

    Thanks for a nice recipe.

  2. I did the same and use “Validate debugger configuartion on web server” option PhpStorm and it is all ok. But the debug is not working. Error shows “Connection with ‘Xdebug 2.7.0’ was not established”. Next to it, it says “Validate installation” and i tried validate and then it says “Xdebug 2.7.0 extension is installed. Check configuration options”. Next to it, it says “Show phpinfo”. upon clicking it show phpinfo and i noticed that “xdebug.remote_enable is set to 0”. Although i set it to 1 in the /usr/local/etc/php/7.3/php.ini file.

    http://snippi.com/s/2x8s5mm

    1. Are you using apache? If yes restart the apache service, if you have set to 1 in the php.ini should be fine. If you prefer post your php.ini here 🙂

  3. Yeah, my install dies with these lines..

    checking whether the C compiler works… no
    configure: error: in `/private/tmp/pear/temp/pear-build-briedisxRDqR2/xdebug-2.8.0beta2′:
    configure: error: C compiler cannot create executables
    See `config.log’ for more details
    ERROR: `/private/tmp/pear/temp/xdebug/configure –with-php-config=/usr/local/opt/php/bin/php-config’ failed

    1. You probably have an old set of developer tools. gcc is reporting its version as 4.0.1. This may be left over from migrating from an older version of the OS. If you’ve installed Xcode 4.3.x, you need to launch it, go into its preferences, select the Downloads tab, and click “Install” next to the Command Line Tools package.

  4. zend_extension=”/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so”
    [PHP]
    zend_extension=xdebug.so
    [xdebug]
    xdebug.remote_enable=1
    xdebug.remote_autostart=1
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=9022

Leave a Reply

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