Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Home Brew - Script to switch between PHP 5.3 and 5.4
#!/bin/bash
# php switch for homebrew
# $ brew tap josegonzalez/php && brew install php53 --with-mysql && brew install php54 --with-mysql
# 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
fi
version=`cat $VERSION_FILE`
if [[ $version == 5.3 ]]; then
ln -sf `brew list php54 | grep libphp` /usr/local/lib/libphp5.so
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
else
ln -sf `brew list php53 | grep libphp` /usr/local/lib/libphp5.so
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
fi
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.