Last active
August 14, 2023 07:36
-
-
Save jonathanbossenger/e480eb5066f9ee5024fd03fafa831b0e to your computer and use it in GitHub Desktop.
Script to switch PHP versions installed with homebrew on a Mac
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
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