Updating php version on mac

Use Homebrew:

I would probably recommend installing homebrew to manage such installations for you. With that installed you can just run the following command to install php7.1

brew update
brew install php@71

The simplest way to update the version of php on Mac is via Homebrew.

If you do not have brew please visit https://brew.sh/ or install via command in terminal:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

When finished installing Homebrew, 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 might get an error if PHP 5.6 has not been installed by brew previously, but don't worry, you can simply continue.

You can also change the version to 7.0 by replacing the command from above commands from brew install php@71 to brew install php@70.

You can check the output by command.

php -v

If the output of php -v still doesn’t echoes the version 7, simply type this command and hit enter in terminal.

export PATH=/usr/local/php5/bin:$PATH

Install php

brew install [email protected]

Install the required PHP to your PATH

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

Then make sure it's all working

php -v
php --version

This command will show you where your ini file is loaded

php --ini

Tags:

Php

Macos