Skip to content

Instantly share code, notes, and snippets.

@jonathanbossenger
Last active August 14, 2023 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanbossenger/e480eb5066f9ee5024fd03fafa831b0e to your computer and use it in GitHub Desktop.
Save jonathanbossenger/e480eb5066f9ee5024fd03fafa831b0e to your computer and use it in GitHub Desktop.
Script to switch PHP versions installed with homebrew on a Mac
NEW_PHP_VERSION=$1
if [ -z "$NEW_PHP_VERSION" ]; then
echo "Please provide a PHP version to switch to."
exit 1
fi
CURRENT_PHP_VERSION=$(php -v | tail -r | tail -n 1 | cut -d " " -f 2 | cut -c 1-3)
brew unlink php@"$CURRENT_PHP_VERSION" && brew link php@"$NEW_PHP_VERSION" --force --overwrite
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment