PLEASE NOTE THE ORIGNAL INFORMATION FOR THIS DOCUMENT AS BEEN TAKEN FROM: https://getgrav.org/
- We want to make sure that we upgrade everything ready to setup
brew update
brew upgrade
brew cleanup
- We want to see what php verisons are currently installed
brew list --formula | grep php
This should return something like:
$ brew list --formula | grep php
php
[email protected]
- Lets remove these to clean everything up
brew uninstall --force php56 php56-apcu php56-opcache php56-xdebug php56-yaml
brew uninstall --force php70 php70-apcu php70-opcache php70-xdebug php70-yaml
brew uninstall --force php71 php71-apcu php71-opcache php71-xdebug php71-yaml
brew uninstall --force php72 php72-apcu php72-opcache php72-xdebug php72-yaml
brew uninstall --force php73 php73-apcu php73-opcache php73-xdebug php73-yaml
brew uninstall --force php74 php73-apcu php74-opcache php74-xdebug php74-yaml
brew uninstall --force php php-apcu php-opcache php-xdebug php-yaml
brew cleanup
You might also need to run it like this:
brew uninstall --force [email protected] php7.3-apcu php7.3-opcache php7.3-xdebug php7.3-yaml
brew cleanup
You can run brew list --formula | grep php
again to make sure everything has been removed.
- Finally remove old config
rm -Rf /usr/local/etc/php/*
- Enable access to php version 8.0
brew tap shivammathur/php
- Install the versions of php you want
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
brew install shivammathur/php/[email protected]
You don't need to install all of the above.
- Your php.ini files are now located here
/usr/local/etc/php/5.6/php.ini
/usr/local/etc/php/7.0/php.ini
/usr/local/etc/php/7.1/php.ini
/usr/local/etc/php/7.2/php.ini
/usr/local/etc/php/7.3/php.ini
/usr/local/etc/php/7.4/php.ini
/usr/local/etc/php/8.0/php.ini
You can you can switching without any additional software using brew directly:
brew unlink php && brew link --overwrite --force [email protected]
Switch to php5.6 can be confirmed with php -v
(assuming this version was installed.
brew unlink php && brew link --overwrite --force [email protected]
Switch to php7.4 can be confirmed with php -v
(assuming this version was installed.
But to make switching a little easier to remember we can use this switching script
- Install the script
curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw/0c36a5067fbd63e6a36700a6aaa119df0836bdfc/sphp.sh > /usr/local/bin/sphp
chmod +x /usr/local/bin/sphp
-
Make sure it can be found via your path, check path using
echo $PATH
to see if it contains:/usr/local/bin
and/usr/local/sbin
if not you can add it too your path. -
You can now switch php version using
sphp 7.1