Drush: Drupal for People Who Hate Mice
(Note that ctools is a required dependency for Views in Drupal 7.)
The Drush dl command (a shortcut for pm-download) is very clever about how it downloads the modules and where it places the extracted folders. By default, it grabs the .tar.gz file from drupal.org and places folders inside the sites/all/modules directory, but you have full control (including using CVS checkouts or where the folders belong). See drush help dl for full details.
As with most tools, people develop their own habits with Drush, but here are a few built-in commands you are likely to appreciate (at least in time):
drush cc (or cache-clear): Drupal developers learn early on to “clear the cache” while developing, because Drupal aggressively caches its more complex internal data structures. Chances are good that if you're writing code, you have a terminal window nearby, and running drush cc all will ensure that when you check your latest work in the browser, you'll accurately see the most recent changes.
drush cron: the Drupal installation guide (INSTALL.txt) recommends running Drupal's periodic maintenance tasks by adding a crontab entry that uses wget to fetch http://example.com/cron.php periodically. In Drupal 7, this now requires a generated “cron_key” parameter as part of the URL to inhibit nefarious requests. Using Drush eliminates the need for the key and avoids tying up a Web server process to do periodic maintenance.
drush up (or pm-update): this command checks drupal.org for new releases for all installed modules and offers to download all updates and run the database upgrades for you. It even handles that pesky, easily forgotten “backup first” step.
Running drush help in your Drupal directory always will give you the list of currently available commands (based on modules installed and so forth). For more information on each command, run drush help <command>.
You may have noticed that we ran our drush commands above from inside the Drupal install directory. This allows Drush to determine which Drupal site (and configuration options) to use. However, for those looking for a bit more freedom and particularly those working within Drupal “multi-site” environments, you need to make use of the --root and --uri switches for Drush. This can lead to a lot of repetitive typing. If you have only a single Drupal site, you can specify these options (and lots more) by creating a .drushrc.php file in your home directory. See the example.drushrc.php file in the examples folder of your Drush installation for more details.
For those of you who work on several Drupal sites across various versions and installations, Drush provides an “alias” mechanism to define the common parameters. To create an alias for this example site here, you can create a file ~/.drush/aliases.drushrc.php containing the following PHP code:
$aliases['example'] = array( 'root' => '/var/www/example/drupal', 'uri' => 'example.com', );
Now you can run drush commands for your example site from any directory using drush @example <command> (for example, drush @example status). To make things even better, aliases can reference remote sites (accessible via SSH) by including the remote-host and remote-user options. See the example.aliases.drushrc.php file from the examples folder in your Drush install directory for full details.
With each new release, Drush includes more commands, and Drupal modules are increasingly offering Drush commands with their releases. If that's not enough (and you aren't afraid of writing some PHP), you can write your own Drush commands. The examples folder in your Drush install includes a sample command, make-me-a-sandwich (XKCD fans rejoice!), for those interested in learning more.
One of the greatest testaments to the power of Drush is the Aegir Hosting Platform (see Resources), which provides a mass-hosting environment (with support for multiserver installations). Although it includes a Web interface, Aegir does all of its heavy lifting via custom Drush commands.
If you work with Drupal and hate using your mouse (or prefer your terminal), Drush can save you countless hours of clicking and open a whole new world of scripted Drupal tasks.
Download Drush 4: drupal.org/project/drush
Handy On-Line Reference (for those who still prefer Web pages): drush.ws
Modules That Already Include Drush Support: drupal.org/project/modules?filters=tid:4654
For Shell Completion Junkies: drupal.org/node/437568
Aegir for Mass-Hosting Drupal: www.aegirproject.org
James Walker is a longtime Drupal developer, consultant, trainer and advocate. He is a co-author of the O'Reilly book Using Drupal and often can be found speaking at Drupal conferences and events. Find him on-line as “walkah” or via walkah.net.
Pick up any e-commerce web or mobile app today, and you’ll be holding a mashup of interconnected applications and services from a variety of different providers. For instance, when you connect to Amazon’s e-commerce app, cookies, tags and pixels that are monitored by solutions like Exact Target, BazaarVoice, Bing, Shopzilla, Liveramp and Google Tag Manager track every action you take. You’re presented with special offers and coupons based on your viewing and buying patterns. If you find something you want for your birthday, a third party manages your wish list, which you can share through multiple social- media outlets or email to a friend. When you select something to buy, you find yourself presented with similar items as kind suggestions. And when you finally check out, you’re offered the ability to pay with promo codes, gifts cards, PayPal or a variety of credit cards.Get the Guide
|Understanding OpenStack's Success||Feb 21, 2017|
|Natalie Rusk's Scratch Coding Cards (No Starch Press)||Feb 17, 2017|
|Own Your DNS Data||Feb 16, 2017|
|IGEL Universal Desktop Converter||Feb 15, 2017|
|Simple Server Hardening||Feb 14, 2017|
|Server Technology's HDOT Alt-Phase Switched POPS PDU||Feb 13, 2017|
- Understanding OpenStack's Success
- Own Your DNS Data
- Simple Server Hardening
- Understanding Firewalld in Multi-Zone Configurations
- Teradici's Cloud Access Platform: "Plug & Play" Cloud for the Enterprise
- From vs. to + for Microsoft and Linux
- Returning Values from Bash Functions
- Tech Tip: Really Simple HTTP Server with Python
- Bash Shell Script: Building a Better March Madness Bracket
- Natalie Rusk's Scratch Coding Cards (No Starch Press)