I remember hearing that homebrew/php was going to be deprecated and migrated to homebrew/core, but I forgot somewhere along the way until I started to update my Brew setup last week. I received a few issues with the automatic homebred-php migration. I am not positive, but I think it had to do with the fact that I had also installed
php71-mcrypt. After doing some research, realized that
php-mcrypt and other extensions that were optional with
homebrew/php are included in the
homebrew/core version of PHP.
Below is what I did to clean up my setup, with details on each step. Note that I currently run PHP 7.1, for Drupal 7 compatibility, but PHP 7.2 is also available.
- Completely uninstall the
$ brew uninstall --force email@example.com
homebrew-phpsince we will not be needing it any longer
$ brew untap homebrew/php
- Next, I ran some brew commands to cleanup dead symlinks and older installs. This is a Brew wide operations, so completely optional if you don’t want to do this part.
$ brew prune && brew cleanup
- Update Homebrew and formulae
$ brew update
- Install the
homebredw-coreversion of PHP 7.1
$ brew install php71
- You can get details on the new PHP setup by running the following
$ brew info php71
- I wanted make sure that Brew version of PHP is in my
$PATHand I ran the following commands suggested via
brew info php71to set this up in my
.zshrc. This can be altered for
$ echo 'export PATH="/firstname.lastname@example.org/bin:$PATH"' >> ~/.zshrc
$ echo 'export PATH="/email@example.com/sbin:$PATH"' >> ~/.zshrc
$ source ~/.zshrc
- When running
php, I received warnings about the expected PHP mcrypt module not being found. I realized that references were probably left in my
php.inifiles form the old
php71-mcryptinstall. Since I didn’t have any specific details in my
php.inifiles that I needed to retain, I removed the Homebrew PHP configuration files and reinstalled PHP with the following. You may want to backup the config before doing this just in case you need to restore some configuration details (Directory to backup /usr/local/etc/php)..
$ rm -rf /usr/local/etc/php
$ brew reinstall firstname.lastname@example.org
After following the above steps, I have a well running Homebrew based PHP install for version 7.1. I have reproduced this on two Macs running macOS 10.13.4, so I wanted to document this in case it helps others.