Mean in green
I'm Kevin. I live in Salem, Mass with my wife and little boy and I build software.

Drush is sweet!

Wednesday Sep 24, 2008

I've been playing around with an awesome Drupal module recently called Drush, which is a CLI interface for common Drupal functions. It's just a PHP script that bootstraps Drupal and calls modules within the Drush module. You can do cool stuff like from managing contributed modules and executing SQL queries, right from the terminal. I've got my head buried in the terminal for ten hours a day anyway, might as well be able to do some Drupal stuff there!

Install is fairly easy:

  1. Download the latest Drush modules for your version
  2. Install them as you would install a normal module
  3. Execute: $ php sites/all/modules/drush/drush.php from your Drupal site's root directory, or add the "-r /path/to/drupal" flag. You might also have to include the "-l http://siteurl.com" flag if you have a multi-site installation
  4. Create a path alias in your .bash_profile, .profile, etc. shell config to, sort of, put it in your path: $ alias drush='php /path/to/sites/all/modules/drush/drush.php -r /path/to/drupal/root'
    1. And, voila! You can now check the watchdog, run cron, run simpletests and a lot more without leaving the comfort of your favorite shell. I'm kind of stoked to write some custom modules to do some other common stuff.