Created
January 19, 2021 11:48
-
-
Save tonning/2b64f00ba3f669f30579d7809986f00c to your computer and use it in GitHub Desktop.
Switch PHP version in MacOS with Homebrew
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
installedPhpVersions=('7.1' '7.2' '7.3' '7.4', '8.0') | |
for phpVersion in ${installedPhpVersions[*]}; do | |
value="{" | |
for otherPhpVersion in ${installedPhpVersions[*]}; do | |
if [ "${otherPhpVersion}" != "${phpVersion}" ]; then | |
value="${value} brew unlink php@${otherPhpVersion};" | |
fi | |
done | |
value="${value} brew link php@${phpVersion} --force --overwrite; } &> /dev/null && php -v" | |
alias "php@${phpVersion}"="${value}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment