-
-
Save Rwrf9/a39326b20459afa99e7db8a60cffeeb9 to your computer and use it in GitHub Desktop.
MAMP switch php version
This file contains hidden or 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/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