[Drush] Manage multiple Drush versions
Can you imagine how it will be to manage Drupal sites without Drush. We may face one issue when Drupal 8 release coming up. Drupal 8 needs the all new version of Drush, and it won't be compatible with older Drupal version 6 and so. Drush version 5 is used to Drupal 6, drupal 8 requires drush of version 8, or else if you have scripts for Drush developed for version 6 or 7 will not work with the latest version of Drush. In this article lets see how we could experiment switching between the Drush versions.
First we need to install composer. Composer is the most perfered way of installing Drush, mostly the latest version. Now lets install drush globally, version 7 is till now the default version.
\> composer global require drush/drush:7.*
Next we need to pick one location to install drush versions. We need drush versions 5 and prior create directories for each of these drush version and these should be inside the user directory.
Let's begin by installing drush versions needed, create directories for the drush versions, To install drush 8, create directory named drush8 inside the directory, run composer command:
\> composer require drush/drush:dev-master
Following the guidlines install other versions of drush also. Now its the key part, creating alias. In the bash profile add the following:
alias drush5='~/drush5/drush' alias drush6='~/drush6/vendor/bin/drush' alias drush7='~/drush7/vendor/bin/drush' alias drush8='~/drush8/vendor/bin/drush'
In the begining since I have installed drush 7 globally, this will act as the default version. We could call other drush versions using the alias name we added.
For example, to check current status using drush 6 execute as follows: \> drush6 status. Other functions drush5 cc css-js
Using the method we will be able to implement multiple Drush versions in our site. Please comment us for further clarifications.