Skip to content

Instantly share code, notes, and snippets.

@paperscissors
Created August 19, 2022 13:41
Show Gist options
  • Save paperscissors/48505df0248695a4faaa0055cc8caa02 to your computer and use it in GitHub Desktop.
Save paperscissors/48505df0248695a4faaa0055cc8caa02 to your computer and use it in GitHub Desktop.
Bash command to switch between multiple versions of PHP on MacOs, Homebrew, and Valet
switchphp () {
phpversion="$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".")"
brew unlink php@$phpversion && brew link php@$1 && valet use php@$1 --force
}
# then switchphp 8.1, switchphp 7.4, whatever versions installed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment