There are several ways to switch between PHP versions on Mac OSX, but one easy way is to use a tool like Homebrew and PHP switcher.
Here are the steps to follow:
1. Install Homebrew by running the following command in your Terminal:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
2. Install PHP switcher by running the following command in your Terminal:
brew install php-switcher
3. Install the PHP versions that you want to switch between. For example, to install PHP 7.3, run the following command:
brew install firstname.lastname@example.org
4. Switch to the desired PHP version by running the following command:
Replace [version_number] with the version number that you want to switch to. For example, to switch to PHP 7.3, run the following command:
Verify that the PHP version has been switched by running the following command:
This should display the version number of the currently active PHP version.
Note: Make sure to update your PATH environment variable to use the new version of PHP. You can do this by adding the following line to your .bashrc or .bash_profile file:
export PATH="$(brew --prefix)/opt/php@[version_number]/bin:$PATH"
Replace [version_number] with the version number of the PHP version you want to use.
Thank you for your time.