问题
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.
回答1:
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
回答2:
// Working as of 2019
As homebrew removed the extra php repository containing a version with xdebug already installed, you have to install it manually.
Summary:
brew install
for php- update your path
pecl install
for xdebug
Full 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
.
回答3:
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
- Go to http://xdebug.org/wizard.php and paste your phpinfo() content there.
- Download xdebug-2.2.5.tgz (http://xdebug.org/files/xdebug-2.2.5.tgz)
Unpack the downloaded file with:
tar -xvzf xdebug-2.2.5.tgz
Run:
cd xdebug-2.2.5
Run phpize (install it via homebrew if you don't have it already)
phpize
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: 220100525Run:
./configure
Run:
make
Run:
cp modules/xdebug.so /usr/lib/php/extensions/no-debug-non-zts-20100525
Edit /etc/php.ini and add the line:
zend_extension = /usr/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
Restart the web server by typing in the terminal:
sudo apachectl restart
回答4:
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
回答5:
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...
回答6:
This is my solution! Try it! ;)
1 Install developer tools:
xcode-select --install
2 Instal Autoconf. This is a tool for producing shell scripts that automatically configure software
brew install autoconf
3 If you use PHP >5.6
sudo pecl install xdebug
Have fun ;)
回答7:
It looks like the repo moved, but it is available here, complete with instructions on how to access it from Homebrew.
回答8:
It helped me to solve zend version and xdebug Xdebug requires Zend Engine API version 320160303. The Zend Engine API version 320180731 which is installed, is newer.
https://xdebug.org/wizard.php
回答9:
Catalina
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
回答10:
If you get this error after adding the tap and installing:
$ brew install "josegonzalez/php/php55"
==> Installing php55 from josegonzalez/php
Error: Formulae found in multiple taps:
* homebrew/php/php53
* josegonzalez/php/php53
Please use the fully-qualified name e.g. homebrew/php/php53 to refer the formula.
it is because josegonzalez/php has been moved to homebrew-php/php recently, so you will face the previous error.
The idea is pretty simple, remove the old deprecated repo josegonzalez/php
brew untap josegonzalez/php
brew tap --repair
brew update
See the source of this solution to fix any other related bugs.
来源:https://stackoverflow.com/questions/12712017/cant-install-xdebug-on-mac-with-homebrew