Skip to content

Instantly share code, notes, and snippets.

@tgeorgel
Last active July 12, 2022 15:46
Show Gist options
  • Save tgeorgel/996c34d7ff73998497366655c3a59ea0 to your computer and use it in GitHub Desktop.
Save tgeorgel/996c34d7ff73998497366655c3a59ea0 to your computer and use it in GitHub Desktop.
Ubuntu Valet : Multiple PHP version management (zsh function)
# 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