The easiest way to upgrade your php version on Mac is through Homebrew.
If you do not have coffee, please visit https://brew.sh/ or install using the command in the terminal:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
After the Homebrew installation is complete, run the following commands:
brew update && brew upgrade brew tap homebrew/dupes brew tap homebrew/versions brew tap homebrew/homebrew-php brew unlink php@56 brew install php@71
You may get an error if PHP 5.6 has not been installed brew before, but don’t worry, you can just continue.
You can also change the version to 7.0 by replacing the above commands with brew install php@71
with brew install php@70
.
You can check the output by command.
php -v
If php -v
output still doesn't reflect version 7, just type this command and hit enter in terminal.
export PATH=/usr/local/php5/bin:$PATH
source share