Intro to Drush


Published on

A brief introduction to the Drush command line utility for Drupal. Learn how to use Drush to quickly build new Drupal sites, simplify the management of existing sites, and even integrate with other systems and IDEs.

Published in: Art & Photos
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Intro to Drush

  1. 1. Intro to Drush July 13, 2012
  2. 2. David Watson Rensselaer Polytechnic Institute − Web Developer Experimental Media and Performing Arts Center (EMPAC) − Adjunct Professor Web Systems Development Drupal Consultant − ~3 years in the community − Specialized Generalist
  3. 3. Development Problems Speed of performing tasks − Site Installation − Module Management − Site Administration − Feature Management − Creating Test Content Ability to script tasks from the shell − Shell scripts − Integration with other systems/IDEs
  4. 4. Solution? Drush! Drupal Shell Command line utility intended for *nix-based environments − Limited Windows support via cygwin Exposes common Drupal tasks via the command line Allows other modules to provide commands − Devel − Features
  5. 5. Drush Installation Drush is not like most other projects! Collection of local scripts, not a module you install on a site Up-to-date installation info can be found on the drush project page −
  6. 6. Site Installation (normal) Open browser Visit Download Drupal Decompress Run install.php from browser Choose install profile Configure site/database
  7. 7. Drupal Download (drush) cd /path/to/destination/dir drush dl − Downloads the latest Drupal version when called with no arguments − Can also be used to download projects
  8. 8. Quick Note... Most other commands that operate on a site must be run from within that sites root directory Running the command within a subdirectory is also acceptable, though supplied paths are generally relative to the Drupal root, not the working directory
  9. 9. Site Installation (drush) drush si [install_profile] − Installs Drupal from scratch, flushing the database first − Optionally accepts the machine name of an install profile − Can supply database information via --db-url flag if necessary
  10. 10. Adding a Module (normal) Open the browser Visit module page on Download the correct module version Decompress the module Move it into the appropriate directory
  11. 11. Adding a Module (drush) drush dl [module_name] − Downloads a module with the given project shortname (the last part of the URL when you visit the project page) − The latest and most stable will be retrieved by default, use --select to be prompted to choose − Modules are downloaded to sites/default/files, use --destination=path/to/dest to specify (relative to Drupal root)
  12. 12. What About Themes? Themes and other projects are downloaded the exact same way Naturally, themes appear in sites/default/themes
  13. 13. Module Management (normal) Visit the module page Scroll through a (usually very) long list Select the module and confirm Confirm dependencies
  14. 14. Module Management (drush) drush en <module_name> − Enables the module drush dis <module_name> − Disables the module drush pm-uninstall <module_name> − Uninstalls a disabled module completely
  15. 15. Module Management (drush) drush up [module_names] − Checks for module updates − Automatically runs update.php − Will even update Drupal core minor releases if out of date! drush pmi <module_name> − Retrieve more information than you could possibly need about a module
  16. 16. Administrative Tasks drush sql-dump --result-file=path/to/dest.sql − Generate a SQL dump of the entire site drush uli <username> − Provides a one-time login link for a user drush upwd <username> − Set the password for a user drush u[u]blk <username> − (un)blocks a given user
  17. 17. Features Integration drush fl − Lists all features and their status drush fd <feature_name> − Takes the diff between features exports in code and database − Requires diff module
  18. 18. Features Integration drush fr <feature_name> − Reverts a feature to code drush fra − Reverts all features at once
  19. 19. Features Integration drush fu <feature_name> − Updates a features code from the current database information, re-exporting it in place drush fe <feature_name> [component_name, ...] − Exports a series of components to a new or existing feature − Adding to an existing feature is “drush fa” before drush 5.x
  20. 20. Devel Integration drush fnv <function> − Display source of a function drush hook <hook_name> − List all hook implementations for examination − The hook name should be without the “hook_” prefix
  21. 21. Devel Integration drush genc <nodes> <comments> − Generate a set number of nodes and comments − --types=types specifies which content types to use Similar command exist for users, taxonomy, etc.
  22. 22. All UI? Never Again! drush si -y empac_cms drush dl feeds drush en -y feeds # UI – oops; broke something! drush fra # UI – hack hack hack drush fe empac_cms_events feeds:events bzr commit -m “Added Feeds Importer”
  23. 23. This is just the start! drush help [command] − Provides detailed help for a given command − Command list and summary given with no arguments Other advanced features exist as well Other modules may provide additional drush integration
  24. 24. Questions?
  25. 25. Get in Touch! d.o – davidwatson e – t - @caughtexception in –