Change mac os x default php version

Chamath Viranga picture Chamath Viranga · Feb 19, 2020 · Viewed 8.6k times · Source

In my mac (version 10.13.6 High Sierra) php -v output is PHP 7.1.32 . I need to update this 7.1 version to 7.3.

i tried to remove this version using brew unlink php7.1 but it's not worked.

How can i upgrade php version.

Answer

Chamath Viranga picture Chamath Viranga · Feb 19, 2020

$ brew upgrade php : ( get the latest homebrew php packages )

$ brew install [email protected] : ( Install php 7.4 )

$ brew link [email protected] : ( create an alias to this keg-only version; see comments output during installation )

$ echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile : ( Add the alias to your path; see comments output during installation )

$ source ~/.bash_profile : ( Reload .bash_profile to use the new settings immediately )

Reference : How to use the php that brew installed?