Skip to content

Instantly share code, notes, and snippets.

@scottrobertson
Created October 29, 2013 13:53
Show Gist options
  • Save scottrobertson/7215083 to your computer and use it in GitHub Desktop.
Save scottrobertson/7215083 to your computer and use it in GitHub Desktop.
function switch_php {
NEW_VERSION="php$1"
EXISTS=`brew info $NEW_VERSION >> /dev/null 2>&1`
if [ ! $? -eq 0 ]
then
echo "PHP Version does not exist"
return 1
fi
echo 'Unlinking other versions'
brew unlink php53 > /dev/null &&
brew unlink php54 > /dev/null &&
brew unlink php55 > /dev/null
echo 'Linking new version'
brew link $NEW_VERSION > /dev/null
echo 'Restarting PHP-FPM'
service php restart > /dev/null
echo "Switched to $NEW_VERSION"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment