Skip to content

Instantly share code, notes, and snippets.

@havvg
Created July 19, 2016 06:33
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havvg/c4018383b02a60f60c2249bd27c791f3 to your computer and use it in GitHub Desktop.
Save havvg/c4018383b02a60f60c2249bd27c791f3 to your computer and use it in GitHub Desktop.
naive homebrew php-switch
# Disables any PHP by unlinking all PHP versions and stopping all PHP services
#
# Enables the PHP of the provided version.
# If no version is provided, no PHP will be enabled, effectively disabling homebrew PHP.
#
# Usage: php-switch 70
php-switch() {
brew list | grep -e ^php..$ | xargs brew unlink
brew services list | grep started | cut -d" " -f1 | grep -e ^php | xargs brew services stop
if [[ $# -eq 1 ]]
then
brew link php$1
brew services start php$1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment