Mac: switch to php8.0 installed by brew

Viewed 1818

After Mac OS full reinstall I perform php 8.0 install by brew install php. Unfortunately, brew didn't make this version active: php --version report about 7.3 (not recommended version). I cannot unlink this version because it's not installed by brew, so brew link also doesn't have much sense. How to bring latest php to system level and completely forget about php7.3 ?

1 Answers

You'll need to tell your terminal where to find your new installed php.

export PATH="/usr/local/opt/php@8.0/sbin:$PATH"

And you need to add it to the bash_profile if you want all terminals to keep using your installed version.

echo 'export PATH="/usr/local/opt/php@8.0/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

This is for terminal use only. So not for your web servers.
In the future, when you install other versions, you can update the profile with:

nano ~/.bash_profile
Related