// Working as of 2025
As homebrew removed the extra php repository containing a version with xdebug already installed, you have to install it manually.
Summary
brew install php@<php version>for php- update your path
pecl install xdebugfor xdebug
Full step-by-step example
# update homebrew
brew update
# install a version of php, e.g. 7.0
brew install [email protected]
# now they tell you how to link it, in my case
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
# reload the file with the updated path, so we can use pecl
source ~/.bash_profile
# check that the path is to the correct php executable,
# and pecl is available
which pecl
# returns: /usr/local/opt/[email protected]/bin/pecl
# install xdebug, see https://xdebug.org/docs/install#pecl
pecl install xdebug
# check that everything worked
php --version
# should show a xdebug version
# like: with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
The pecl install xdebug step above ended with
Build process completed successfully
Installing '/usr/local/Cellar/[email protected]/7.0.30/pecl/20151012/xdebug.so'
install ok: channel://pecl.php.net/xdebug-2.6.0
Extension xdebug enabled in php.ini
So I didn't even need to enable the xdebug.so in php.ini.
Troubleshooting
Need for some specific xdebug version
If you need a special version of xdebug (e.g. your IDE doesn't like the 3.x.x versions), you can install a specific version xdebug-$VERSION, e.g. pecl install xdebug-2.9.8.
You can find them on the list of available versions
(Thanks Bower)
Xcode not installed or ERROR: `phpize' failed.
xcrun --show-sdk-path || sudo code-select --install
(Thanks Louis Charette and Bernievv)
Error Warning: mkdir(): File exists in System.php on line 294 or ERROR: failed to mkdir /usr/local/Cellar/php/X.Y.Z/pecl/YYYYMMDD
The folder specified for extensions does not exists. Create it like the following:
mkdir -p "$(pecl config-get ext_dir)"
(Thanks Patrique Ouimet)
Answer from luckydonald on Stack Overflow// Working as of 2025
As homebrew removed the extra php repository containing a version with xdebug already installed, you have to install it manually.
Summary
brew install php@<php version>for php- update your path
pecl install xdebugfor xdebug
Full step-by-step example
# update homebrew
brew update
# install a version of php, e.g. 7.0
brew install [email protected]
# now they tell you how to link it, in my case
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
# reload the file with the updated path, so we can use pecl
source ~/.bash_profile
# check that the path is to the correct php executable,
# and pecl is available
which pecl
# returns: /usr/local/opt/[email protected]/bin/pecl
# install xdebug, see https://xdebug.org/docs/install#pecl
pecl install xdebug
# check that everything worked
php --version
# should show a xdebug version
# like: with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
The pecl install xdebug step above ended with
Build process completed successfully
Installing '/usr/local/Cellar/[email protected]/7.0.30/pecl/20151012/xdebug.so'
install ok: channel://pecl.php.net/xdebug-2.6.0
Extension xdebug enabled in php.ini
So I didn't even need to enable the xdebug.so in php.ini.
Troubleshooting
Need for some specific xdebug version
If you need a special version of xdebug (e.g. your IDE doesn't like the 3.x.x versions), you can install a specific version xdebug-$VERSION, e.g. pecl install xdebug-2.9.8.
You can find them on the list of available versions
(Thanks Bower)
Xcode not installed or ERROR: `phpize' failed.
xcrun --show-sdk-path || sudo code-select --install
(Thanks Louis Charette and Bernievv)
Error Warning: mkdir(): File exists in System.php on line 294 or ERROR: failed to mkdir /usr/local/Cellar/php/X.Y.Z/pecl/YYYYMMDD
The folder specified for extensions does not exists. Create it like the following:
mkdir -p "$(pecl config-get ext_dir)"
(Thanks Patrique Ouimet)
Add this repository: https://github.com/josegonzalez/homebrew-php#readme
Then use brew install php54-xdebug for PHP 5.4
Or brew install php53-xdebug for PHP 5.3
Or brew install php55-xdebug for PHP 5.5
Laravel Herd is now out!
Help to get PHP8 w/ xdebug in Docker on OSX running for local dev (phpunit) via PhpStorm in a checkout project
Install PHP 7.2 + xdebug on MacOS High Sierra (with homebrew as of July 2018)
Docker solved such a headaches.
More on reddit.com