-
-
Save indytechcook/3775631 to your computer and use it in GitHub Desktop.
a php switching utillity for homebrew
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# php switch for homebrew | |
# $ brew tap josegonzalez/php && brew install php53 --with-mysql && brew install php54 --with-mysql | |
# Please add '/usr/local/Cellar/php/bin' to the beginning of your PATH variable to enable the command line binaries. | |
# Might as well ask for password up-front, right? | |
sudo -v | |
# Check the command-line argument and create version variable. | |
if [ -z $1 ] | |
then | |
echo "*** Please provide a PHP version." | |
exit 1 | |
fi | |
version=$1 | |
shortVersion=$(echo "$version" | tr -d '.') | |
echo "Switching to: PHP $version" | |
# Check that the formula/package exists in homebrew and fetch PHP directory. | |
phpPackage="php$shortVersion" | |
phpDir="$(brew --prefix $phpPackage)" | |
if [ $? -eq 1 ] | |
then | |
echo "*** PHP directory not found. Version not installed from homebrew?\n" | |
exit 1 | |
fi | |
echo "PHP dir: $phpDir" | |
# Regenerate link to the correct PHP directory. | |
brew unlink phpPackage | |
brew link phpPackage | |
# Change libphp5.so installation. | |
libSource=$(brew list "$phpPackage" | grep libphp) | |
if [ -z "$libSource" ] | |
then | |
echo "*** Could not find suitable libphp5.so for package $phpPackage." | |
exit | |
fi | |
echo "Library: $libSource" | |
ln -sf "$libSource" /usr/local/lib/libphp5.so | |
# my version of running apache http://drupal.org/project/feather | |
feather restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment