Last active
November 15, 2022 21:29
-
-
Save nataliaalves03/ca7fa8e478b6da8402a39cea967d1ee8 to your computer and use it in GitHub Desktop.
Set PHP version
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 | |
ERROR="\e[91m" | |
INFO="\e[94m" | |
SUCCESS="\e[92m" | |
ENDCOLOR="\e[0m" | |
if [ -z "$1" ]; then | |
echo "${ERROR}Missing PHP version. Try: sh php-version.sh 8.1${ENDCOLOR}" | |
exit 0 | |
fi | |
echo "${INFO}Setting PHP version $1 ${ENDCOLOR}" | |
sudo update-alternatives --set php /usr/bin/php$1 | |
sudo update-alternatives --set phar /usr/bin/phar$1 | |
sudo update-alternatives --set phar.phar /usr/bin/phar.phar$1 | |
echo "${SUCCESS}Done! Check the PHP version...${ENDCOLOR}" | |
php --version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment