Drupal - Organizing Your Modules With Drush
I’ve been using Drush for some time now for Drupal development. Especially for downloading, enabling, and updating modules, it is considerably quicker than doing things by hand.
Another practice I’ve also taken to is putting all downloaded modules in a contrib/
folder instead of simply in sites/all/modules/
. This makes my custom modules stand out much more than they would otherwise, which is a good thing for multi-developer sites or for just generally taking a look at what custom code a site is using.
Drush, however, by default, puts everything you download via drush dl mymodule
into sites/all/modules/
. There’s a --destination
parameter, but I would quickly tire of having to remember that every time. But, there’s a quick an easy solution using a drushrc
file.
If you don’t already have a drushrc setup, you’ll need to make one in your .drush
folder in your home directory. You can make any number of drushrc files in ~/.drush/
, as long as they all end in drushrc.php
.
Here’s the one I created and named aliases.drushrc.php
(just in case I want to add more aliases later):
1
2
3
<?php
$command_specific['dl'] = array('destination' => 'sites/all/modules/contrib');
?>
For my next trick, I’m going to try Homesick, a Ruby gem for helping your dot files follow you around, so I can get this file created everywhere I need it.