Skip to content

Instantly share code, notes, and snippets.

@Rwrf9
Created October 3, 2017 10:08
Show Gist options
  • Select an option

  • Save Rwrf9/a39326b20459afa99e7db8a60cffeeb9 to your computer and use it in GitHub Desktop.

Select an option

Save Rwrf9/a39326b20459afa99e7db8a60cffeeb9 to your computer and use it in GitHub Desktop.
MAMP switch php version
#!/bin/bash
if [[ $(id -u) -eq 0 ]]; then
echo "The command \"sphp\" should not be executed as root or via sudo directly."
exit 1
fi
# Usage
if [ $# -ne 1 ]; then
echo "Usage: sphp [phpversion]"
echo "Versions installed:"
cd /Applications/MAMP/bin/php; ls -d php* | while read -r line ; do
echo "${line//php}"
done
exit 1
fi
version="${1//php}"
if [ ! -d "/Applications/MAMP/bin/php/php$version/bin" ]; then
echo "Version $version not exist!"
exit 1
fi
rm /Applications/MAMP/bin/php/current
ln -s /Applications/MAMP/bin/php/php$version/bin /Applications/MAMP/bin/php/current
# show new version
php -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment