HackMonkey

Demystifying Drupal

Book Review: Drush User's Guide

June 5, 2012 - 10:12am

Fear not the CLI, the Command Line can be your friend, trust the HackMonkey on this one! Drush is a perfect example of all that is wonderful about using a Command Line Interface with Drupal. To start off Drush can install Drupal & modules, clear the cache, enable & disable modules, backup sites, sync entire sites, wash the dishes, help you drink more beer, walk your dog, and make you look more attractive! Ok, it will not walk your dog or wash the dishes, but it can do all the rest and sanitize a database. That is kind of like washing the dishes, right? Don't believe me, fine. Check out this piece of classic Drupal cinema for more proof, Drush: More Beer, Less Effort. With all that extra efficiency you are bound to look more attractive to clients, right!

So now you understand why Drush is so awesome, and Packt Publishing's new book, Drush User's Guide is here to help you become a Drush Master. This book helps you jump right in and get going with Drush. It has lots of examples and has plenty for the novice Drupal chimp to the veteran Drupal gorilla. Authored by Juan Pablo Novillo Requena, a Drush contributor; it is also technically reviewed by Greg Anderson and Jonathin Araña Cruz, Drush co-maintainers and contributors respectively. There are no monkeys at the keyboard on this book.

The book immediately dives into installing Drush, it wastes no time explaining what Drupal is or the value of Open Source. You should have a grasp on those already. It goes into detail on how to install Drush on Linux, Windows & Mac and several different ways to do so. It is also up to date, covering Drush 5. Although a better job might have been done noting that some of the covered items are Drush 5 only. However, since the current stable release of Drush at the time of this review is Drush 5.4, it is a very minor point.

The book has 4 chapters and 119 pages, so it is easy to get through. The first 2 chapters cover installing Drush and the basic commands that any novice can master. The last 2 chapters cover more advanced topics.

All the basics like installing Drupal core, downloading modules, enabling modules, clearing the caches, and such are in these first 2 chapters. I was surprised Site Aliases weren't mentioned here, but they are covered in the third chapter, so keep reading even if you are a novice! While perhaps a bit on the advanced side, variables are also covered in the second chapter. Working with variables at the command line with Drush is a really powerful skill, and can save the day if you have a set variable cause a white screen. The Monkey did learn a valuable nugget on variables here as well. The HackMonkey knew how to set and unset Drupal variables with Drush, but didn't realize Firebug could dig the variable names out of the rendered page. There is also some great stuff on dealing with databases, monitoring Watchdog and using cron in the second chapter. There is one very minor typo in an example, the command to use cron is "drush cron", not "drushcron". However, since all Drush commands start with drush, a space and then the command, that is a pretty easy one to figure out.

The third chapter dives into the more advanced stuff, like writing our own commands, executing PHP from the command line, and optimizing the terminal with the core-cli command.  To make the most of these tools, some knowledge of PHP, SQL, and the Drupal API will be required. Site aliases and Drush config files are also covered, and are powerful tools that any Drush user can leverage. In the beginning of the book the example of syncing a development and production database with the simple command $ drush sql-sync @somewebsite.com @somewebsite.local is shown. Chapter 3 explains how this is done with site aliases.

The last chapter covers how Drush can interact with other modules from the command line, instead of pecking through the GUI. This falls into the category of "which are you more comfortable with?", the CLI or the GUI. There is a nice demo on using Drush to create a boilerplate starting point for building a module, which will save the habitual module builder some time.

The very last topic in the book just happens to be the one thing about Drush that the HackMonkey literally is bananas over - Drush Make! This fantastic tool can literally download Drupal core, all the modules and themes a site needs, apply patches, grab external libraries pull from Git repos and numerous other things with something as simple as $ drush make mysite.make mysite.com. Drush Make is awesome, read this section! The book doesn't cover all the different things that Drush Make can do, but the readme file included with Drush Make does. Drush Make is such an incredible time saver, it takes less than a minute for Drush Make to pull all the code together for hackmonkey.com!

Conclusion

Drush is awesome, and should be in every Drupal site builders tool box. The Drush User's Guide is a great resource for those just getting started with Drush, or for those looking to take their Drupal mastery to the next level of efficiency. At the start of the book, it is mentioned that commands would be shown full length, instead of the shorter command aliases. Anyone that uses Drush for any amount of time, wll quickly want to adopt the aliases. For example cache-clear becomes cc, watchdog-show aliases to ws and pm-download shortens to dl. While a cheat sheet of Aliases might have been a nice inclusion as an appendix, the good news is that all the aliases and extended syntax for all of Drush's commands are nicely documented on the Drush website, drush.org.

Disclaimer

The copy of Drush User's Guide that was used for this review was provided at no charge to Scott Wilkinson of HaloFX Media LLC by Packt Publishing. However, no other compensation was received for this review and this review was published without prior review or any influence from Packt Publishing.