To install multiple PHP versions on a Mac using Brew, follow the steps below:
Multiple PHP version on Mac - Install php and config |
bash
Copy code
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install the required dependencies using the following commands:
arduino
Copy code
brew install autoconf automake curl gettext libiconv libmcrypt libtool pkg-config
Install PHP versions by running the following commands:
graphql
Copy code
brew install [email protected]
brew install [email protected]
brew install [email protected]
brew install [email protected]
Once the installation is complete, check the installed PHP versions by running the following command:
perl
Copy code
brew list | grep php
Create symbolic links for each PHP version to make them easily accessible using the following commands:
perl
Copy code
brew link --force --overwrite [email protected]
brew link --force --overwrite [email protected]
brew link --force --overwrite [email protected]
brew link --force --overwrite [email protected]
Finally, verify the installation and configuration by checking the version of each PHP installation using the following commands:
graphql
Copy code
You can also switch between different PHP versions using the brew unlink and brew link commands. For example, to switch to PHP 7.3, run the following commands:
perl
Copy code
brew unlink [email protected]
brew link --force --overwrite [email protected]
This will set PHP 7.3 as the default version, and you can verify it by running php -v command.