Now that homebrew has fully deprecated the old PHP channel and merged everything within the code,
things have changed. Before you were able to install anything using a command like
brew install php- but
now it won't work anymore.
The new way is simple and easy (not), so follow me:
First, you will need to make sure the old taps or anything old you have (maybe just moves them to another directory).
Second, update and clean up your
brewinstallation, run those commands for example:
brew update && brew upgrade brew doctor
and fix any issue you see.
Install PHP via brew by running
brew install phpwhich will install PHP 7.2 by default.
annoyingpart (for me), which I can't blame them for it nor I can say anything about, is installing xdebug with
pecl, that's correct we are back to use
pecl install xdebug
After that running
php -v will complain about not finding
xdebug and that's because PHP load the extensions
from a directory while PECL installs them in a different one.
In my case PHP loads them from the following path
And PECL installs them at the following path
My simple solution was to symbolic xdebug file to the path that PHP load by running
cd /usr/local/Cellar/php/7.2.4_1/lib/php/20170718 ln -s /usr/local/Cellar/php/7.2.4_1/pecl/20170718/xdebug.so
So my advice for you is to read the log correctly, as this will help you a lot and spare you a lot of time. Also,
remember to run
php -m before installing anything.