brew search php
brew install [email protected]
brew install [email protected]
brew install [email protected]
brew install [email protected]
brew install [email protected]
brew link [email protected]
php -v
Now that you have all versions installed, you can switch between them effortlessly. Add this function to your .zshrc
:
# Switch PHP version
function sphp() {
Yellow='\033[0;33m'
Color_Off='\033[0m'
brew unlink php@$1 && brew link --overwrite --force php@$1
echo "${Yellow}Validating current PHP Version${Color_Off}"
php -v
}
sphp 7.4
sphp 8.0
sphp 8.1
sphp 8.2
sphp 8.3