Created
August 5, 2014 04:53
-
-
Save jcdarwin/c4b4dc52450a3f6cad2f to your computer and use it in GitHub Desktop.
Running PHP under WAMP
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
We prefer to point to our WAMP PHP CLI as our system-wide PHP CLI version, and we do this by | |
including the following script at /usr/local/bin/php: | |
#!/bin/bash | |
# e.g. php="/cygdrive/c/Program Files (x86)/php/php.exe" | |
php="/cygdrive/c/wamp/bin/php/current/php.exe" | |
for ((n=1; n <= $#; n++)); do | |
if [ -e "${!n}" ]; then | |
# Converts Unix style paths to Windows equivalents | |
path="$(cygpath --mixed ${!n} | xargs)" | |
case 1 in | |
$(( n == 1 )) ) | |
set -- "$path" "${@:$(($n+1))}";; | |
$(( n < $# )) ) | |
set -- "${@:1:$((n-1))}" "$path" ${@:$((n+1)):$#};; | |
*) | |
set -- "${@:1:$(($#-1))}" "$path";; | |
esac | |
fi | |
done | |
echo "$@" | |
"$php" "$@" | |
ensuring that /usr/local/bin/php appears foremost in our path | |
creating a symlink which points /cygdrive/c/wamp/bin/php/current to our current version of PHP: | |
ln -s /cygdrive/c/wamp/bin/php/php5.3.13 /cygdrive/c/wamp/bin/php/current | |
To ensure that this symlink is updated when we want to change our PHP CLI version, we can use the following script (php.switch): | |
#!/usr/bin/bash | |
# Allows us to change the CLI version of PHP, which is governed by the | |
# /cygdrive/c/wamp/bin/php/current symlink. | |
function switch { | |
PHP="/cygdrive/c/wamp/bin/php" | |
unlink $PHP/current | |
ln -s $PHP/$1 $PHP/current | |
echo "" | |
echo "cli php path changed:" | |
ls -la $PHP/current | |
} | |
echo " " | |
echo "Current versions of PHP are:" | |
echo "1. 5.3.13" | |
echo "2. 5.4.26" | |
echo " " | |
echo "Select the version you'd like to configure WAMP to use [1 or 2]:" | |
select version in "1" "2"; do | |
case $version in | |
1 ) switch php5.3.13; break;; | |
2 ) switch php5.4.26; break;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment