I\'m kind of new to using Homebrew, but I love it. It\'s so easy. I\'m trying install Xdebug. Some of the posts on the web say to do this:
brew install xd
I'd found this page while googling how to install xdebug for php 7.1
on osx, and I've decided to leave here my solution:
brew install homebrew/php/php71-xdebug
Maybe it'll be helpful for someone else in future...
Starting with Catalina (Mac OS 10.15) PHP seems to be pre-installed (check with php -v
) It could be installed along xcode or another software (I'm not sure) But I just installed Catalina yesterday and haven't installed Homebrew yet, Also xdebug is available too. I just had to rename /etc/php.ini.default
and add this line
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so
It looks like the repo moved, but it is available here, complete with instructions on how to access it from Homebrew.
Updated: 09-10-2019
For PHP 5.6 & 7.0 (not anymore in brew core)
brew tap exolnet/homebrew-deprecated
Use brew bundled pecl (when php installed with brew)
PHP 5.6 example
brew install php@5.6
$(brew --prefix php@5.6)/bin/pecl install --force xdebug-2.5.5
PHP 7.0 example
brew install php@7.0
$(brew --prefix php@7.0)/bin/pecl install --force xdebug
PHP 7.1 example
brew install php@7.1
$(brew --prefix php@7.1)/bin/pecl install --force xdebug
PHP 7.2 example
brew install php@7.2
$(brew --prefix php@7.2)/bin/pecl install --force xdebug
PHP 7.3 example
brew install php@7.3
$(brew --prefix php@7.3)/bin/pecl install --force xdebug
or link with brew first
PHP 5.6 example
brew install php@5.6
brew link --force php@5.6
pecl install --force xdebug-2.5.5
brew unlink php@5.6
PHP 7.0 example
brew link --force php@7.0
pecl install --force xdebug
brew unlink php@7.0
PHP 7.1 example
brew link --force php@7.1
pecl install --force xdebug
brew unlink php@7.1
PHP 7.2 example
brew link --force php@7.2
pecl install --force xdebug
brew unlink php@7.2
PHP 7.3 example
brew link --force php@7.3
pecl install --force xdebug
brew unlink php@7.3
If php -v gives you an error stating xdebug.so could not be found (assuming the pecl install went well) then you could have "old" settings like php.ini Un-/reinstalling php with brew does not remove ini files. Upgrading php to the new format does not update ini files. Just reinstall php with brew after you removed the folder /usr/local/etc/php/5.6/ and xdebug should work.
The new brew php installation does not link. You could do that yourself if you would like to (brew link --force php@5.6) Als you could install brew-php-switcher to switch between versions.
brew install brew-php-switcher
brew-php-switcher 5.6 -s
php -v
brew-php-switcher 7.0 -s
php -v
Keep in mind if you loaded php as a service you have to restart the service.
brew services restart php@7.0
As homebrew removed the extra php repository containing a version with xdebug already installed, you have to install it manually.
Summary:
brew install <php version>
for phppecl install xdebug
for xdebugFull example:
# update homebrew
brew update
# install a version of php, e.g. 7.0
brew install php@7.0
# now they tell you how to link it, in my case
echo 'export PATH="/usr/local/opt/php@7.0/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.0/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/php@7.0/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/php@7.0/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
.