This custom drush command will make you a better Drupal developer


When faced with a repetitive development task I like to throw a bash script at the problem. And nothing elevates the power of a bash script in Drupal development more than using Drush.

Drush is a command line tool for managing a Drupal site. It’s a developers best friend. But the real power of Drush is in writing your own custom Drush commands.

Whenever I start a new Drupal project I drop in a special Drush command I wrote to quickly make a local installation developer friendly. I call it drush golocal. This command enables developer friendly modules like Devel, Stage File Proxy, and Views UI, enables email rerouting so your local install doesn’t send emails to users, disables a bunch of internal Drupal caching, and sets some helpful permissions.

I place this code in a custom module in a special include file where drush looks for commands: EXAMPLE.drush.inc.

As development continues (and after launch for support), this is the perfect place to add site-specific changes that relate only to that project (such as switching to development instances of third-party systems to which your site connects).

Bonus Points!

Now that you have a handy way to put a site into development mode in your local installation, consider integrating this script into your dev/stage/production workflow. If you use a platform like Acquia Cloud that provides deployment hooks, you can have this routine run every time you copy the production database to the dev server automagically.

You can even take it a step further and write a bash script that downloads a copy of the production database, imports it into your local install, and then runs this command. Suddenly you can update your local environment from production and have it ready for development with one simple command.

Launch your idea with Third & Grove

Contact Us

And yes, our staff will probably jump out of a plane for you.

Justin is CTO & co-founder of Third and Grove. He has worked on both sides of the technology world, both in internal technology departments and as a consultant delivering services to those on the inside. He has a passion for best practices, good engineering, and pragmatic code. Justin is the author of Pro Web Project Management (Apress, 2011), a pragmatic guide to managing web projects. He has a degree in Psychology from the University of Southern California and not Computer Science because, as he told his skeptical parents at the wise age of 17, "There is no money in computers." Justin is always on the look out for a tasty new craft beer.