Insight | Aug 6, 2014
Five Drush commands I can’t live without
By Justin Emond
Drush is our Drupal command line tool of choice at Third and Grove. We automate or simplify everything we can with drush, from using drush release scripts for seamless launches to custom drush commands that make development more efficient.
Here are five Drush commands I use frequently that I can’t live without:
drush fu MODULE_NAME
Features is a big part of how we build, test, and deploy Drupal at Third and Grove. This command automatically captures any overridden Drupal systems in your features module MODULE_NAME and downloads the entire module source code of MODULE_NAME over the current module. No more exporting, unarchiving, and copying files. (And yes, the command also captures any code level changes to any files in your module, so those aren’t lost.)
drush cc all
It’s well known that the first debug step in Drupal is clearing the Drupal cache. This simple command flushes all (most of the time) of Drupal’s cache.
drush uli USERNAME
This handy command will give you a one-time login link for any user account on your site so you can quickly login as that user. This is very helpful for troubleshooting permissions issues and you have to access a client account where you can’t and don’t want to change the password.
drush php-script FILENAME.php
Sometimes you need to write a custom throw-away script to perform some cleanup. Since it’s one-time you don’t want to write a custom Drupal module, but you would still like to have access to the full Drupal API. Enter
php-script
. This command boots up the Drupal API then runs any php file you point it to, where you have full access to the Drupal api. This command is vital in drush release scripts.drush sql-drop
MySQL doesn’t have a command to drop every table in a database while preserving the database itself, but sometimes that is exactly what you need to do.
sql-drop
does just that: it loops through every table in your database and drops it. Simple but very handy when writing scripts to automate updating your local from production.
Bonus!
drush golocal
This isn’t a core Drush command but a custom command we use on all of our projects. It makes your local Drupal instance very developer friendly.
drush @server.environment ANY-DRUSH-COMMAND
Drush aliases let you run any drush command on a remote server from your local machine via the magic of SSH key-based authentication. We won’t go into how to set this up in this post, but if you use a platform like Acquia or Pantheon they are already set up for you. They are also very easy to set up with your own server once you see an example. Use them!
Drop us a line
Have a project in mind?
Contacting Third and Grove may cause awesomeness. Side effects include a website too good to ignore. Proceed at your own risk.