Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Last active Feb 4, 2022
Embed
What would you like to do?
php switching for taskfile
unlink_php() {
PHP_CURRENT=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".");
PHP_LATEST=$(ls /usr/local/Cellar/php | cut -f1-2 -d".");
echo "Your current PHP version is ${PHP_CURRENT}";
echo "The latest version of PHP installed is ${PHP_LATEST}";
echo "Unlinking PHP ${PHP_CURRENT}...";
if [ ${PHP_CURRENT} = ${PHP_LATEST} ]; then
brew unlink php
else
brew unlink php@${PHP_CURRENT}
fi
}
php7() {
unlink_php
echo "Linking php 7.4..."
brew link php@7.4
}
php8() {
unlink_php
echo "Linking php 8"
brew link php@8.0
}
php81() {
unlink_php
echo "Linking php 8.1"
brew link php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment