Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Hacky PHP Switch script
# php switch for homebrew
# $ brew tap josegonzalez/php && brew install php53 --with-mysql && brew install php54 --with-mysql
# modified from original basic script from somewhere on the interweb, I don't remember where
# Might as well ask for password up-front, right?
sudo -v
VERSION_FILE="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/php-switch.version"
if [[ ! -f $VERSION_FILE ]]; then
echo "5.4" > $VERSION_FILE
version=`cat $VERSION_FILE`
if [[ $version == 5.3 ]]; then
ln -sf `brew list php54 | grep libphp` /usr/local/lib/
brew unlink php54 && brew link php54 --overwrite
export PATH="$(brew --prefix php54)/bin:$PATH"
echo "Switched to 5.4"
echo `brew info php54 | head -1`
echo "5.4" > $VERSION_FILE
ln -sf `brew list php53 | grep libphp` /usr/local/lib/
brew unlink php53 &&brew link php53 --overwrite
export PATH="$(brew --prefix php53)/bin:$PATH"
echo "Switched to 5.3"
echo `brew info php53 | head -1`
echo "5.3" > $VERSION_FILE
sudo apachectl restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.