Discovering Drush: Drupal's Swiss Army Knife
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
No Downloads

Views

Total Views
5,573
On Slideshare
5,546
From Embeds
27
Number of Embeds
4

Actions

Shares
Downloads
72
Comments
2
Likes
8

Embeds 27

http://nextleveldrupal.com 13
http://www.nextleveldrupal.com 9
http://drupalcampalberta.org 4
http://www.drupalcampalberta.org 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Discovering Drush Drupal’s Swiss Army Knife Joshua Schroeder Drupal Camp Alberta 2010 September 12, 2010
  • 2. Session Resources ๏ Presentation slides (http://slideshare.net/jdschroeder and http://jdschroeder.ca) ๏ Presentation video (http://drupalcampalberta.org and http://vimeo.com/drupalcampab) 2
  • 3. General assumptions ๏ Who will get the most out of this presentation: ๏ You are reasonably comfortable using command-line utilities. ๏ You know the general concepts of Drupal. ๏ See what Drush can do and how to use it. 3
  • 4. What is Drush? ๏ Drupal shell ๏ Not a module ๏ Collection of scripts that allow you to perform Drupal tasks from the command line on your web server. 4
  • 5. So why should I care? ๏ Do you spend a lot of time at a command prompt? ๏ Accomplish admin tasks quicker than via the web interface. ๏ Scriptability of common tasks. ๏ Keeping up to date. 5
  • 6. All that, and smart, too ๏ Drush knows what site you’re working on. ๏ Drush knows what version of Drupal you are using. 6
  • 7. Requirements ๏ To be run alongside your Drupal installations (i.e. on a server). ๏ Requires command-line access to PHP 5.2. 7
  • 8. Getting Drush ๏ http://drupal.org/project/drush ๏ Current release is 3.3. ๏ Download and extract on your server. 8
  • 9. Installing Drush ๏ See README.txt ๏ Make the Drush script executable. ๏ Create a symlink in /usr/local/bin or create an alias. 9
  • 10. Configuration ๏ Global and site specific drushrc.php files ๏ Configures path locations, site aliases, checkout handling, database dump options, command-specific options, and variable overrides. ๏ example.drushrc.php is included. 10
  • 11. Using Drush ๏ $ drush [options] <command> 11
  • 12. Did I say all versions? ๏ Not all commands are available to all Drupal versions. ๏ site-install requires Drupal 7, several other commands require at least Drupal 6. 12
  • 13. Drush commands what exactly does it do? 13
  • 14. Help! ๏ $ drush ๏ $ drush help <command> 14
  • 15. Core commands ๏ core-cli ๏ core-cron ๏ core-rsync ๏ core-status ๏ drupal-directory 15
  • 16. Package management ๏ pm-disable (dis) ๏ pm-download (dl) ๏ pm-enable (en) ๏ pm-info ๏ pm-list (sm) ๏ pm-refresh (rf) ๏ pm-releases ๏ pm-uninstall ๏ pm-update (up) ๏ pm-updatecode 16
  • 17. Database ๏ sql-conf ๏ sql-connect ๏ sql-dump ๏ sql-query ๏ sql-sync 17
  • 18. Watchdog ๏ watchdog-delete ๏ watchdog-list ๏ watchdog-show 18
  • 19. Variables ๏ variable-delete ๏ variable-get ๏ variable-set 19
  • 20. Site commands ๏ site-alias (sa) ๏ site-install (si) ๏ site-upgrade ๏ updatedb 20
  • 21. site-install Demo http://www.youtube.com/watch? v=I7s2YnTWAc0 21
  • 22. Extending Drush ๏ Features ๏ features-diff, features-export, features-list, features-revert, features-revert-all, features-update, features-update-all ๏ Devel generate ๏ generate-content, generate-taxonomy, generate-users 22
  • 23. Drush Make ๏ www.drupal.org/project/drush_make ๏ Create a ready-made Drupal site from the command-line. ๏ Useful for distributing installation profiles. 23
  • 24. A Drush makefile ๏ From www.openatrium.com/node/35 core="6.x" projects[] = "drupal" projects[openatrium][type] = "profile" projects[openatrium][download][type] = "cvs" projects[openatrium][download][module] = "contributions/profiles/openatrium" projects[openatrium][download][revision] = "DRUPAL-6--1-0-BETA4" 24
  • 25. make Demo http://www.youtube.com/watch? v=VOvRrMGUo7I 25
  • 26. As if by magic 26
  • 27. ...and more, and more ๏ Other modules can add new Drush functionality per-site. ๏ www.drupal.org/project/modules?filters=tid %3A4654&solrsort=sis_project_release_usage %20desc 27
  • 28. Development Server 28 Production Server Deployment example
  • 29. Deployment example Development Production Server Server drush dl drush sql-sync [source] [destination] drush si drush rsync [source] [destination] drush dl [modules] drush en 29
  • 30. Site aliasing $options['site-aliases']['remote_site'] = array( 'uri' => 'myremotesite.com', 'root' => '/var/www/html/remotesite.com', 'db-url' => 'mysql://username:password@localhost/database', 'remote-host' => 'myremotesite.com', 'remote-user' => 'user_deploy', 'path-aliases' => array( '!drush' => '/usr/local/bin/drush', '!drush-script' => '/usr/local/bin/drush/drush', '!files' => 'sites/default/files', ), ); 30
  • 31. Syncing files and data ๏ $ drush rsync sites/default remote_site:sites ๏ $ drush sql-sync development remote_site 31
  • 32. Want to learn more? ๏ Documentation on Drupal.org ๏ Session from the developers of Drush at DrupalCons in 2009 and 2010: ๏ http://dc2009.drupalcon.org/session/drush-command-line-drupal- productivity ๏ http://sf2010.drupal.org/conference/sessions/drush ๏ http://sf2010.drupal.org/conference/sessions/advanced-drush 32
  • 33. Questions www.jdschroeder.ca 33