Can't install xdebug on Mac with Homebrew - xdebug
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.
// Working as of 2023
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 php
update your path
pecl install xdebug for xdebug
Full step-by-step 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.
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)
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
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: 220100525
Run:
./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
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
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...
Xdebug on Big Sur for php8
php8 previously installed with brew.
~ % pecl install xdebug
ERROR: `phpize' failed
Ouch! Check xcrun. Thank you Louis Charette:
~ % xcrun --show-sdk-path
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Error. Update Xcode. I just installed, and retest:
~ % xcode-select --install
xcode-select: note: install requested for command line developer tools
~ % xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
That's better! Now go back and try pecl again:
~ % pecl install xdebug
...
Build process completed successfully
Installing '/usr/local/Cellar/php/8.0.0_1/pecl/20200930/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.0.2
Extension xdebug enabled in php.ini
And check it worked:
~ % php -v
PHP 8.0.0 (cli) (built: Nov 30 2020 13:51:52) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies
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 ;)
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
macOS 10.14 Mojave, Homebrew, PHP 7.3, April 2020
The description given in the following article was the only thing I could get to work on macOS 10.14 Mojave with Homebrew to install PHP 7.3 with working xdebug:
brew list | grep php | awk '{ print "brew uninstall --force "$1}' | bash # Remove any old version of php.
rm -rf /usr/local/Cellar/php # To be sure, manually remove the php cellar folder.
brew untap homebrew/php # Then clean any php tap (extra repo).
brew cleanup # Cleanup and Update your brew.
brew update
brew install php # Install the latest version of php.
pecl uninstall xdebug # Clean up old xdebug.
pecl install xdebug-beta # Install the latest version of xdebug-beta (The xdebug is not compatible with 7.3 so you need to use the xdebug-beta).
php -v # Should now say "with Xdebug v2.9.4, Copyright (c) 2002-2020, by Derick Rethans"
It looks like the repo moved, but it is available here, complete with instructions on how to access it from Homebrew.
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.
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
As at May 2021, after installing PHP via Homebrew just run this:
pecl install xdebug
You'll need XCode installed as above answers have indicated.
The other answers involving other brew repositories or php74-* package namespaces are based on the old way Homebrew worked with PHP.
Improved Answer for MacOS
If you have followed the instructions written on the official docs and cannot see XDebug info using php -v command and instead getting errors, the last step you should do is the following:
Go to the 99-xdebug.ini file you made in the described path and add this line:
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20180731/xdebug.so"
(still errors? check your xdebug.so path if it is valid)
After saving the changes, restart php using the command below:
brew services restart php#7.3 (change 7.3 with your php version)
Then check if you can now see XDebug info using php -v command.
NOTE: "Described path" for 99-xdebug.ini is something like:
/usr/local/etc/php/7.3/conf.d (change 7.3 with your php version)
To be sure, type php --ini command.
Related
PECL installation conflict isssue
I am trying to install Pear package using following command sudo yum install php-dev php-pear But it's giving me following error: Transaction check error: file /usr/bin/php from install of php-cli-5.4.16-48.el7.x86_64 conflicts with file from package ea-php-cli-1.0.0-9.13.1.cpanel.x86_64 I am installing this package for sqlsrv driver but I am not able to do.
It seems you using WHM/cpanel right? Don't install extensions using CLI. You can install it using PECL installer in WHM dashboard. here the screenshot of PECL module installer But if the module is not available on the GUI installer, you can install the module using built-in PHP from the cPanel. the path of pecl executable is /usr/bin/ea-phpVERSION-pecl. an example if you want to install sqlsrv on php 7.3: /usr/bin/ea-php73-pecl install pdo_sqlsrv reference: https://support.cpanel.net/hc/en-us/articles/360053132353-How-install-pdo-sqlsrv-to-connect-to-MSSQL-Servers
Running into problems installing MongoDB on MacOS Terminal
I am trying to install mongoDB as a macOS service but I am running to some errors I first put in the terminal brew tap mongodb Nothing really happens. But, when I run: brew install mongodb-community#5.0 I receive: Warning: No available formula with the name "mongosh" (dependency of mongodb/brew/mongodb-community). Did you mean mongocli? ==> Searching for similarly named fo This similarly named formula was found: mongocli ✔ To install it, run: brew install mongocli ✔ It was migrated from mongodb/brew to homebrew/core. Finally, when I run brew services start mongodb-community#5.0 I receive Error: Formula 'mongodb-community' is not installed. Any advice?
I had the same happen, however my issue was actually with this error: fatal: could not solve HEAD to a revision solve it using: git -C $(brew --repository homebrew/core) checkout master you can also: brew update brew upgrade brew upgrade --cask brew cleanup and then restart the mongodb community edition install process again! Worked for me!
I am experiencing the exact same problem (I am using MacOC version 11.5.1). The reason why your brew tap mongodb does not seem to be doing anything may be because you have already tapped into mongodb. Try untapping with brew untap mongodband retapping with brew tap mongodb/brew. After you have established the connection, try installing again with brew install mongodb-community#5.0. At this stage, I could not get the installation to work for version 5.0 so I installed version 4.4 instead (with brew install mongodb-community#4.4). After that, try running mongo with brew services start mongodb-community#5.0 (or brew services start mongodb-community#4.4 if you have installed 4.4 version) and it should work just fine! If you have installed version 4.4, be sure to run the command PATH="/usr/local/opt/mongodb-community#4.4/bin" mongo to start the mongo shell.
I was also having the same issue. This solved it for me: git -C $(brew --repository homebrew/core) checkout master brew update brew upgrade brew upgrade --cask brew cleanup Then install the latest version of Mongodb community using: brew install mongodb-community#6.0 Note: version might be outdated at the time you're reading this
Check with brew list | grep mongo that mongodb-community, mongodb-database-tools, mongosh exist at your PC. If they do not exist, install them with brew. Recently also installed mongodb V4.4.5 and can not start it with brew services start mongodb-community. For me works starting it manually as a background process as admin sudo mongod --config /usr/local/etc/mongod.conf --fork And last call mongo to work with mongoDB shell. Reason: directory/file access issue. Not sure.
wxPython Installation failure
I am trying to install wxPython on a new installation of Ubuntu 18.04 using the command pip3 install wxPython The build fails with error: [Errno 2] No such file or directory: 'build/lib.linux-x86_64-3.6/wx/libwx_baseu-3.0.so' ---------------------------------------- Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-30uqzd2e/wxPython/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-hynl659w-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-30uqzd2e/wxPython/ I have no idea where to look for a solution. Can someone please suggest where I might start [EDIT 20200424 08:06] I looked in /usr/lib/x86_64-linux-gnu/ and libwx_baseu-3.0.so.0 was absent. I have installed it from this site It is now present, but the install fails with the same message
I have managed to install wxPython. I reinstalled Ubuntu 18.04 and performed the following: sudo apt install make gcc libgtk-3-dev libwebkitgtk-dev libwebkitgtk-3.0-dev libgstreamer-gl1.0-0 freeglut3 freeglut3-dev python-gst-1.0 python3-gst-1.0 libglib2.0-dev ubuntu-restricted-extras libgstreamer-plugins-base1.0-dev pip3 install wxpython I guess that when it was failing I had tried many fixes and somewhere along the line something was corrupted or there was a mismatch somewhere. My solution was based on this answer
I Installed wx.python 4.1.0 yesterday with: URL=https://extras.wxpython.org/wxPython4/extras/linux/gtk2/ubuntu-18.04 pip install -U -f $URL wxPython See: https://extras.wxpython.org/wxPython4/extras/ for details. For gtk3 simply replace gtk2 in the url above.
CakePHP 3.0 installation: intl extension missing from system
Using the CakePHP docs, I am trying to install 3.0-beta2 using composer but I got this error: cakephp/cakephp 3.0.x-dev requires ext-intl * -> the requested PHP extension intl is missing from your system However, I know for sure that intl is installed (it shows on phpinfo). I'm using PHP 5.4.33/Apache 2.4.10.1
I faced the same problem today. You need to enable the intl PHP extension in your PHP configuration (.ini). Solution Xampp (Windows) Open /xampp/php/php.ini Change ;extension=php_intl.dll to extension=php_intl.dll (remove the semicolon) Copy all the /xampp/php/ic*.dll files to /xampp/apache/bin Restart apache in the Xampp control panel Solution Linux (thanks to Annamalai Somasundaram) Install the php5-intl extension sudo apt-get install php5-intl 1.1. Alternatively use sudo yum install php5-intl if you are on CentOS or Fedora. Restart apache sudo service apache2 restart Solution Mac/OSX (homebrew) (thanks to deizel) Install the php5-intl extension brew install php56-intl If you get No available formula for php56-intl follow these instructions. Restart apache sudo apachectl restart Eventually you can run composer install to check if it's working. It will give an error if it's not.
I faced the same issue in ubuntu 12.04 Installed: sudo apt-get install php5-intl Restarted the Apache: sudo service apache2 restart
OS X Homebrew (May 2015): The intl extension has been removed from the main php5x formulas, so you no longer compile with the --enable-intl flag. If you can't find the new package: $ brew install php56-intl Error: No available formula for php56-intl Follow these instructions: https://github.com/Homebrew/homebrew-php/issues/1701 $ brew install php56-intl ==> Installing php56-intl from homebrew/homebrew-php
When using MAMP 1 Go to terminal vim ~/.bash_profile i export PATH=/Applications/MAMP/bin/php/php5.6.2/bin:$PATH Change php5.6.2 to the php version you use with MAMP Hit ESC, Type :wq, hit Enter source ~/.bash_profile which php 2 Install Mac Ports https://www.macports.org/install.php sudo port install php5-intl OR sudo port install php53-intl cp /opt/local/lib/php/extensions/no-debug-non-zts-20090626/intl.so /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626/ {take a good look at the folder names that u use the right ones} 3 Add extension Now, add the extension to your php.ini file: extension=intl.so Usefull Link: https://gist.github.com/irazasyed/5987693
The error message clearly states what the problem is. You need the intl extension installed. Step 1: install PHP intl you comfortable version $sudo apt-get install php-intl step 2: For XAMPP Server intl extension is already installed, you need to enable this extension to uncomment below the line in your php.ini file. Php.ini file is located at c:\xampp\php\php.ini or where you have installed XAMPP. Before uncomment: ;extension=php_intl.dll ;extension=php_mbstring.dll After uncommenting: extension=php_intl.dll extension=php_mbstring.dll
Short answer: activate intl extension in php_cli.ini. Thanks to #ndm for his input.
If you are using latest version Ubuntu 16.04 or later just do sudo apt-get install php-intl Then restart your apache sudo service apache2 restart
In my case I was not actually trying to run cakephp locally, I was just trying to get it to auto update locally using composer (because I am playing with writing plugins that you install with composer). Since I don't actually even run it locally I could simply ignore requirements by adding the --ignore-platform-reqs flag. php composer.phar update --ignore-platform-reqs
In my case, my running php version is 7.1.x on mac OSX . I installed intl command using brew install php71-intl. Placing extension=intl.so inside php.ini was no effect at all. Finally i looked for extension installed directory and there i saw intl.so and placed that path (extension=/usr/local/Cellar/php71-intl/7.1.11_20/intl.so) to my php.ini file and it solved my problem.
In my case (xampp PHP 8.0) Find ;extension=intl in /xampp/php/php.ini Remove ; and Restart Apache
MAKE this In XAMPP, intl extension is included but you have to uncomment extension=php_intl.dll in php.ini and restart the server through the XAMPP Control Panel. In WAMP, the intl extension is “activated” by default but not working. To make it work you have to go to php folder (by default) C:\wamp\bin\php\php{version}, copy all the files that looks like icu*.dll and paste them into the apache bin directory C:\wamp\bin\apache\apache{version}\bin. Then restart all services and it should be OK. if you use XAMPP do this 1. turn off XAMPP 2. Modifed the php.ini is located in c/:xampp/php/php.ini 3. intl extension is included but you have to uncomment extension=php_intl.dll in php.ini and restart the server through the XAMPP Control Panel.
For Ubuntu terminal: Please follow the steps: Step-1: cd ~ Step -2: Run the following commands sudo apt-get install php5-intl Step -3: You then need to restart Apache sudo service apache2 restart For Windows(XAMPP) : Find the Php.ini file: /xampp/php/php.ini Update the php.ini file with remove (;) semi colon like mentioned below: ;extension=php_intl.dll to extension=php_intl.dll and save the php.ini file. After that you need to Restart the xampp using xampp control.
Intl Means :Internationalization extension which enables programmers to perform UCA-conformant collation and number,currency,date,time formatting in PHP scripts. To enable PHP Intl with PECL can be used. pecl install intl On a plain RHEL/CentOS/Fedora, PHP Intl can be install using yum yum install php-intl On Ubuntu, PHP Intl can be install using apt-get apt-get install php5-intl Restart Apache service for the changes to take effect. That's it
For those who get Package not found error try sudo apt-get install php7-intl then run composer install in your project directory.
I had the same problem in windows The error was that I had installed several versions of PHP and the Environment Variables were routing to wrong Path of php see image example
I'm using Mac OS High Sierra and none of these worked for me. But after searching a lot I found one that worked! This may seem trivial, but in fact about 2 months ago some clever guys made changes in brew repository, so doing just: brew install php71-intl will show you error with message that such recipe doesn’t exists. Fortunately, there is. There is temporary fix in another brew repo, so all you have to do is: brew tap kyslik/homebrew-php brew install kyslik/php/php71-intl SOURCE: http://blastar.biz/2018/04/14/how-to-enable-php-intl-extension-for-php-7-1-using-xampp-on-macos-high-sierra/
I use Linux Ubuntu 20, you can try this: Check php installed modules: php -m | grep intl If there are no result(s) from this command, you should just go ahead and install the module: sudo apt-get install php7.4-intl you will need to change *php7.4 to your desired php version. you should restart apache when you're done: sudo service apache2 restart
Class 'Locale' not found issue on CakePHP 3
I'm just downloaded the files from this link, extracted and tried execute but I had this error: Fatal error: Class 'Locale' not found in D:\xampp\htdocs\cake-3-beta-2\vendor\cakephp\cakephp\src\I18n\I18n.php on line 229 I'm running on localhost with xampp... I had the same issue with beta 1 and 2.
I faced the same problem today. You need to enable the intl PHP extension in your PHP configuration (.ini). Solution Xampp (Windows) Open /xampp/php/php.ini Change ;extension=php_intl.dll to extension=php_intl.dll (remove the semicolon) Copy all the /xamp/php/ic*.dll files to /xampp/apache/bin Restart apache in the Xampp control panel Solution Linux (thanks to Annamalai Somasundaram) Install the php5-intl extension sudo apt-get install php5-intl 1.1. Alternatively use sudo yum install php5-intl if you are on CentOS or Fedora. Restart apache sudo service apache2 restart Solution Mac/OSX (homebrew) (thanks to deizel) Install the php5-intl extension brew install php56-intl If you get No available formula for php56-intl follow these instructions. Restart apache sudo apachectl restart Eventually you can run composer install to check if it's working.
Change in php ini file For Older php version ;extension=php_intl.dll to extension=php_intl.dll For New php versions ;extension=intl to extension=intl