$ xcode-select --install
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
$ brew --version
$ brew doctor
$ sudo apachectl stop
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
$ brew install nginx
$ sudo brew services start nginx
$ brew install php@5.6
$ brew install php@7.0
$ brew install php@7.1
$ brew install php@7.2
$ brew unlink php@7.2 && brew link --force --overwrite php@5.6
I fixed all my migration related issues (regarding the most-current-version 7.2) with:
# Save all old configurations, so the new packaes can recreate their versions -- eases the migration
mv /usr/local/etc/php $HOME/old-brew-php
# Uninstall ALL php related Packages (most of them homebrew/php related)
brew list | grep php | xargs brew uninstall --force
# Remove deprecated tap
brew untap homebrew/php
# Clean cache
brew cleanup
# Ensure latest brew repo HEAD
brew update
# Install latest php (php 7.2)
brew install php
pecl install xdebug
# Now copy & paste specific conf.d from your old-brew-php version if needed
# after that you may dispose of the old-brew-php folder
Older versions may be installed with the @ syntax. e.G. php@7.1 or php@5.6
You also need to add some lines to php.ini or to a file you create in for ex. /usr/local/etc/php/7.1/conf.d/. The lines should look like:
[xdebug]
zend_extension="/usr/local/opt/php/lib/php/<somedir>/xdebug.so"
In my case (php 7.2), I have a file /usr/local/etc/php/7.2/conf.d/ext-xdebug.ini that contains these lines.