[xdebug]
# Using https://github.com/w00fz/xdebug-osx/ so don't add `zend_extension` entry, as it would be duplicate
# https://xdebug.org/docs/all_settings
xdebug.remote_port=9001
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_connect_back=1
xdebug.var_display_max_depth=-1
xdebug.var_display_max_children=-1
xdebug.var_display_max_data=-1
Before we get started, see where PHP is loading from for reference: which php
will be /usr/local/bin/php if from native Mac OS X instead of Homebrew.
If you're a pre-existing Homebrew PHP user, follow this guide to fully uninstall all your past stuff.
Make sure ready to get started: brew doctor
If good, then install latest version of PHP:
brew install php
After success, add Homebrew's linked (i.e. currently running) PHP version in your .zshrc
# PHP from the currently linked Homebrew PHP version
export BREW_PHP=/usr/local/var/homebrew/linked/php/bin
export PATH="$BREW_PHP:$PATH":"~/Dropbox/bin":/usr/local/bin
In a new terminal window, which php
should now return /usr/local/var/homebrew/linked/php/bin/php
xdebug-toggle is handy! Follow install and usage instructions from its README.md, but here is a snippet:
bin
folder)curl -L https://raw.githubusercontent.com/w00fz/xdebug-osx/master/xdebug-toggle > ~/Dropbox/bin/xdebug-toggle
chmod +x ~/Dropbox/bin/xdebug-toggle
xdebug-toggle # outputs the current status
xdebug-toggle on # enables xdebug
xdebug-toggle off # disables xdebug
xdebug-toggle on|off --no-server-restart # toggles xdebug without restarting apache or php-fpm
In general, keep Xdebug disabled unless you need it. Running Codeception tests with it enabled will be extra slow, but at least now, with this setup, you can hit your breakpoints during it if running Xdebug.
Per https://xdebug.org/docs/install, run pecl install xdebug
Now find where PECL loads from:
php -r "echo ini_get( 'extension_dir' );"
should return something like /usr/local/lib/php/pecl/20180731
(the date is the API version installed; not important)
Go to this API folder and make sure xdebug.so
is in it.
Go to /usr/local/etc/php/7.3/conf.d
(if 7.3 is the version Homebrew installed) and create your ext-xdebug.ini
file (attached)
You'll need to copy this file to all other PHP versions you install via Homebrew, if any.
pecl
dir is a symlink like mine somehow was or is otherwise not a directory, delete it, then try installing Xdebug again.brew install autoconf
brew install automake
xdebug.so
file to where it belongsphp --ini
should mention parsing your ext-xdebug.ini
filephp -v
should mention Xdebug's version if it's runningxdebug-toggle off
should restart PHPphp --ini
to confirm ext-xdebug.ini
is no longer includedxdebug-toggle on
if you want to re-enable Xdebugbrew install composer
is easy
Update your .zschrc as follows:
alias composer='/usr/local/var/homebrew/linked/composer/bin/composer'
A)
/usr/local/var/homebrew/linked/php/bin/php
B)
/usr/local/var/homebrew/linked/composer/bin/composer
C)
I wrote my own guide because none of these did 100% for me, but each were helpful in their own way and may be specific to any issues you encounter if my guide isn't 100% for you.
My guide...
sphp
to switch PHP versions (other versions installed via Homebrew, which this guide did not cover), then I don't have to update my scripts or PhpStorm locations~/Dropbox/bin
(manually created) location so changes are versioned and synced between multiple computers and is in an easy-to-remember location if I ever want to make changesIn case they might help you:
This guide came from here (synced so whichever is your preference):