Drush Training

Like Terminus, at first you will not deal directly with Drush a lot. Additionally, when you do deal with Drush it will be in connection with Terminus. So, let us talk a bit about Drush, watch and then do some reading about it. 

Drush is a command line tool we use in our Ubuntu shell to interact with our websites. Normally, for Drush to work you have to be in the project (website) folder. That means that in Ubuntu you would need to "cd" into the websites' folder. Since we use Drush via Terminus that is not required. When we use Drush via Terminus you have to specify which site you are working on. I will give an example later and it will make more sense.

Drush has a long list of commands that you can find at Drush Commands. This is a really useful website as you can go and look up commands and their structure. 

Before you spend too much time looking up commands go to this tutorial and read through it. Do not bother to try and practice any of these in your Ubuntu yet. The reason why I don't want you to practice them is that if you get them to work you will actually be interacting with the site and that is not what we want to be doing at the moment. Drush and Terminus can have a very significant positive and negative impact on the site so be careful when you use them. 

Our tutorial is A Beginner's Guide to Drush: The Drupal Shell.

Now that you have worked through that and have a general understanding of how Drush works, let me talk a little bit about using it with Terminus. We use Drush via Terminus which means we have to follow the Terminus syntax. Let me give you an example and then talk you through it. In your Ubuntu shell type:

terminus drush sitename.env -- cr

This command will clear and rebuild the registry on the site named. Let us walk through it. 

"terminus" - tells Ubuntu you want to do a terminus command.

"drush" - tells Ubuntu that within Terminus you want to use a Drush command.

"sitename.env" - tells Ubuntu which website and environment you want to target with the command. "sitename" is the name of the website. In the case of this website it is samhales. When you use Ubuntu and "cd" into the websites folder the name will show up in your command path. Enter this into the "sitename" position. Then add a period "." and type in the environment you want to target. Remember, Pantheon always has at a minimum a dev, test, and live environment.  

"--" - this command tells Ubuntu that the actual Drush command is coming. 

" cr" - this is the actual Drush command. Add a space after "--" and type in your Drush command. In this case "cr" is the clear registry command.

And there you are. You are on your way with Drush via Terminus.