Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AllieRays/50f1b3f18bdb60be1d3a88df66962777 to your computer and use it in GitHub Desktop.
Save AllieRays/50f1b3f18bdb60be1d3a88df66962777 to your computer and use it in GitHub Desktop.
#!/bin/bash
#Switch between PHP 7.4 and 8.0 and Drush Version 8 and 11
# To use this script download this file and name it switch-php.sh
# and give it the correct permissions
# You can then run ./switch-php
# with the argument 7.4 or just ./switch-php
# For example ./switch-php 7.4
## First need to download PHP Versions
## brew tap shivammathur/php
## brew install shivammathur/php/php@8.1
## brew install shivammathur/php/php@7.4
## confirm PHP 7.4 is not in the bash_profile path
#Switch to PHP 7.4 and Drush 8.x
if [[ $1 == "7.4" ]];
then
echo "------------------ PHP 7.4 ------------------------"
brew unlink PHP
brew link --force --overwrite php@7.4
# Remove the current version of drush.
composer global remove drush/drush
# Install drush version 8
composer global require drush/drush:8.x
else
# Switch to PHP 8.1 and Drush 11.
echo "------------------ PHP 8.1 ------------------------"
brew unlink PHP
brew link --force --overwrite php@8.1
# Remove the current version of drush.
composer global remove drush/drush
# Install drush version 11
composer global require drush/drush
fi
# Show Me
echo "------------------------------------"
drush status
php --version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment