Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I easily switch between PHP versions on Mac OSX?

Tags:

php

macos

I would like to test my application on PHP 5.3 up to PHP 7.0.

Where and how can I install the versions and how can I switch them by running a small script?

like image 874
Xaver Avatar asked Jan 20 '16 19:01

Xaver


People also ask

How do I change PHP version in terminal Mac?

To update the PHP version, update the brew using the command brew update . Then, use the command brew upgrade php . It upgrades the current version to the latest version of PHP. Then, restart the webserver to see the changes.


1 Answers

If you have both versions of PHP installed, you can switch between versions using the link and unlink brew commands.

For example, to switch between PHP 7.4 and PHP 7.3

brew unlink [email protected] brew link [email protected] 

PS: both versions of PHP have be installed for these commands to work.

like image 77
Goke Obasa Avatar answered Sep 21 '22 18:09

Goke Obasa