xxxxxxxxxx
# List available PHP versions
brew search php
# Install a specific PHP version
brew install php@7.4
# Switch to the installed PHP version
brew link --overwrite --force php@7.4
# Verify the PHP version
php -v
xxxxxxxxxx
brew upgrade php : ( get the latest homebrew php packages )
$ brew install php@7.4 : ( Install php 7.4 )
$ brew link php@7.4 : ( create an alias to this keg-only version; see comments output during installation )
$ echo 'export PATH="/usr/local/opt/php@7.4/bin:$PATH"' >> ~/.bash_profile : ( Add the alias to your path; see comments output during installation )
$ source ~/.bash_profile : ( Reload .bash_profile to use the new settings immediately )
xxxxxxxxxx
brew unlink php && brew link php // php 8.2
brew link --overwrite php@7.4 // php 7.4