How to swop between different PHP versions on an Apple Mac

Follow the procedure in blue:

  project git:(master) php -v                               
PHP 7.4.33 (cli) (built: Jul 13 2023 17:41:11) ( NTS )
...
  project git:(master) brew unlink [email protected] && brew link --force [email protected]
Unlinking /opt/homebrew/Cellar/[email protected]/8.1.21... 40 symlinks removed.
Unlinking /opt/homebrew/Cellar/[email protected]/7.4.33_4... 259 symlinks removed.
Linking /opt/homebrew/Cellar/[email protected]/8.1.21... 239 symlinks created.
If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
  echo 'export PATH="/opt/homebrew/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
  project git:(master) php -v
PHP 8.1.21 (cli) (built: Jul  6 2023 16:08:36) (NTS)
...

If you have Laravel Valet, also do this:

  project git:(master) cd ~/Code

  project git:(master) valet install

 

 

Tags

Share this article

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top