Skip to content

Instantly share code, notes, and snippets.

@niepi
Forked from torifat/php-switch
Created August 27, 2013 17:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niepi/6356372 to your computer and use it in GitHub Desktop.
Save niepi/6356372 to your computer and use it in GitHub Desktop.
#!/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
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
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