Last active
July 12, 2022 15:46
-
-
Save tgeorgel/996c34d7ff73998497366655c3a59ea0 to your computer and use it in GitHub Desktop.
Ubuntu Valet : Multiple PHP version management (zsh function)
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
# Change PHP version | |
php-v () { | |
if [[ $1 -eq '' ]] | |
then | |
version="8.1" # default php version | |
else | |
version="$1" | |
fi | |
# kill all php-fpm processes | |
sudo service php7.4-fpm stop | |
sudo service php8.0-fpm stop | |
sudo service php8.1-fpm stop | |
# update php cli | |
sudo update-alternatives --set php /usr/bin/php$version | |
# update php fpm (with valet) | |
valet use $version | |
# display php version | |
service --status-all | grep "\-fpm" | |
php -v | grep "(cli)" | |
} | |
# Usage : | |
#> php-v 8.0 | |
#> php-v 7.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment