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-<package> 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
brew installation, run those commands for example:
brew update && brew upgrade
and fix any issue you see.
* Install PHP via brew by running
brew install php which will install PHP 7.2 by default.
* Now the
annoying part (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
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
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.