Can't install xdebug on Mac with Homebrew

2019-03-09 07:56发布

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 xdebug

But it doesn't work. I get: Error, no available formula.

I did brew search xdebug and it returned:

josegonzalez/php/php53-xdebug    josegonzalez/php/php54-xdebug

I tried several different iterations of brew install with this including brew install php53-xdebug, but still no luck. Can someone help me? I can't find anything on Xdebug's site about using Homebrew, but yet posts on the web seem to indicate it's possible.

8条回答
beautiful°
2楼-- · 2019-03-09 08:15

Forget about homebrew for a moment. I have tried doing with it and it is not a that good idea stability-wise. Instead stick to the default installation guide:

Installing XDebug on Mac OSX

  1. Go to http://xdebug.org/wizard.php and paste your phpinfo() content there.
  2. Download xdebug-2.2.5.tgz (http://xdebug.org/files/xdebug-2.2.5.tgz)
  3. Unpack the downloaded file with:

    tar -xvzf xdebug-2.2.5.tgz

  4. Run:

    cd xdebug-2.2.5

  5. Run phpize (install it via homebrew if you don't have it already)

    phpize

  6. As part of its output it should show (If it does not, you are using the wrong phpize):

    Configuring for: ...
    Zend Module Api No: 20100525
    Zend Extension Api No: 220100525

  7. Run:

    ./configure

  8. Run:

    make

  9. Run:

    cp modules/xdebug.so /usr/lib/php/extensions/no-debug-non-zts-20100525

  10. Edit /etc/php.ini and add the line:

    zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so

  11. Restart the web server by typing in the terminal:

    sudo apachectl restart

查看更多
地球回转人心会变
3楼-- · 2019-03-09 08:16

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 (7.0 is now EOL and not by default in brew core)

git -C "$(brew --repo homebrew/core)" fetch --unshallow
git -C "$(brew --repo homebrew/core)" checkout 7e111a877^
HOMEBREW_NO_AUTO_UPDATE=1 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 does not work (yet) needs xdebug 2.7.0

or link

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

git -C "$(brew --repo homebrew/core)" fetch --unshallow
git -C "$(brew --repo homebrew/core)" checkout 7e111a877^
HOMEBREW_NO_AUTO_UPDATE=1 brew install php@7.0
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 does not work (yet) needs xdebug 2.7.0

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.

查看更多
登录 后发表回答