How to Install, Use, and Customize Drush

67
Drush: The essential Drupal tool Tuesday, November 29, 2011

description

View a recording of this presentation at http://www.acquia.com/resources/acquia-tv/conference/biggest-increase-your-drupal-productivity-how-install-use-and

Transcript of How to Install, Use, and Customize Drush

Page 1: How to Install, Use, and Customize Drush

Drush:  The  essential  Drupal  tool

Tuesday, November 29, 2011

Page 2: How to Install, Use, and Customize Drush

@JacobSingh

Trainer Engineer Speaker

About  me

http://jacobsingh.name

Tuesday, November 29, 2011

Page 3: How to Install, Use, and Customize Drush

@JacobSingh

Lover Fighter Whiskers

About  movember

HTTP://TINYURL.COM/JACOBMO

Tuesday, November 29, 2011

Page 4: How to Install, Use, and Customize Drush

What  do  programmers  hate  more  than  

anything?  

Tuesday, November 29, 2011

Page 5: How to Install, Use, and Customize Drush

Work  that  is

Tuesday, November 29, 2011

Page 6: How to Install, Use, and Customize Drush

Tedious

Tuesday, November 29, 2011

Page 7: How to Install, Use, and Customize Drush

&  Repetitive

Tuesday, November 29, 2011

Page 8: How to Install, Use, and Customize Drush

Introducing

Tuesday, November 29, 2011

Page 9: How to Install, Use, and Customize Drush

Drush!

Tuesday, November 29, 2011

Page 10: How to Install, Use, and Customize Drush

Drupal  +  shell

Tuesday, November 29, 2011

Page 11: How to Install, Use, and Customize Drush

What  the  shell?

Tuesday, November 29, 2011

Page 12: How to Install, Use, and Customize Drush

The  Shell

• a.k.a.  Terminal,  Command  Line,  CLI

• Type  commands  to  interact  with  your  computer

• Windows  =  DOS  and  PowerShell

• Linux  /  OSX  =  bash,  sh,  rsh

Tuesday, November 29, 2011

Page 13: How to Install, Use, and Customize Drush

Tuesday, November 29, 2011

Page 14: How to Install, Use, and Customize Drush

Exercise:  Open  the  shell

Tuesday, November 29, 2011

Page 15: How to Install, Use, and Customize Drush

Windows

• Click  on  Start

• Type  “cmd”  into  the  program  search

• Hit  enter  to  select  the  command  prompt

Tuesday, November 29, 2011

Page 16: How to Install, Use, and Customize Drush

OSX

• Go  to  Applications  -­‐>  Utilities

• Click  on  terminal

Tuesday, November 29, 2011

Page 17: How to Install, Use, and Customize Drush

Exercise:  Installing  Drush

Tuesday, November 29, 2011

Page 18: How to Install, Use, and Customize Drush

pear channel-discover pear.drush.orgpear install drush/drush

* Windows is a little different. See http://drush.ws

Tuesday, November 29, 2011

Page 19: How to Install, Use, and Customize Drush

Why  Drush?

• Speed

• Automation

Tuesday, November 29, 2011

Page 20: How to Install, Use, and Customize Drush

Drush  can  do  a  lot  of  things

Tuesday, November 29, 2011

Page 21: How to Install, Use, and Customize Drush

command (cmd)description.

Tuesday, November 29, 2011

Page 22: How to Install, Use, and Customize Drush

Let’s  try  a  few

Tuesday, November 29, 2011

Page 23: How to Install, Use, and Customize Drush

cache-clear (cc) Clear a specific cache, or all

drupal caches.

Tuesday, November 29, 2011

Page 24: How to Install, Use, and Customize Drush

Exercise:  Download  Drupal

Tuesday, November 29, 2011

Page 25: How to Install, Use, and Customize Drush

pm-download (dl) Download projects from drupal.org or

other sources.

Tuesday, November 29, 2011

Page 26: How to Install, Use, and Customize Drush

Downloading  Drupal

dl drupalDrush

Tuesday, November 29, 2011

Page 27: How to Install, Use, and Customize Drush

Exercise:  Install  Drupal

Tuesday, November 29, 2011

Page 28: How to Install, Use, and Customize Drush

Tuesday, November 29, 2011

Page 29: How to Install, Use, and Customize Drush

site-install (si) Install Drupal along with modules/

themes/configuration using the specified install profile.

Tuesday, November 29, 2011

Page 30: How to Install, Use, and Customize Drush

drush site-installCould not find a Drupal settings.php file

at ./sites/default/settings.php. Could not determine database connection

parameters. . Pass --db-url option

Tuesday, November 29, 2011

Page 31: How to Install, Use, and Customize Drush

Pass --db-url option

Tuesday, November 29, 2011

Page 32: How to Install, Use, and Customize Drush

Pass --db-url option.

Tuesday, November 29, 2011

Page 33: How to Install, Use, and Customize Drush

Drush  command  Structure

Command Options Arguments

Tuesday, November 29, 2011

Page 34: How to Install, Use, and Customize Drush

site-install --db-url=mysql://....

cache-clear theme

Examples

Run the install command, using the db-url “mysql://...” (no arguments)

Clear the theme cache (no options)

dl drupal

Download Drupal to /tmp/drupal

--destination=/tmp/drupal

Tuesday, November 29, 2011

Page 35: How to Install, Use, and Customize Drush

Most  important  option!!!!

Tuesday, November 29, 2011

Page 36: How to Install, Use, and Customize Drush

--help

Tuesday, November 29, 2011

Page 37: How to Install, Use, and Customize Drush

--helpsite-installLists all of the options and arguments for the site-

install command. Also provides examples.

Tuesday, November 29, 2011

Page 38: How to Install, Use, and Customize Drush

Exercise:  Adding  modules

Tuesday, November 29, 2011

Page 39: How to Install, Use, and Customize Drush

Download  views

dl viewsDrush

Tuesday, November 29, 2011

Page 40: How to Install, Use, and Customize Drush

Project views (7.x-3.0-rc3) downloaded to www/sites/all/modules/

views. Project views contains 2 modules:

views, views_ui.

Tuesday, November 29, 2011

Page 41: How to Install, Use, and Customize Drush

Exercise:  Enabling  modules

Tuesday, November 29, 2011

Page 42: How to Install, Use, and Customize Drush

pm-enable (en) Enable one or more extensions

(modules or themes).

Tuesday, November 29, 2011

Page 43: How to Install, Use, and Customize Drush

Enable  views

en views views_uiDrush

Tuesday, November 29, 2011

Page 44: How to Install, Use, and Customize Drush

Any  questions  before  we  continue?

Tuesday, November 29, 2011

Page 45: How to Install, Use, and Customize Drush

Updating  modules

dl webform-7.x-3.11Drush

upc webformDrush

updatedbDrush

en webformDrush

--no-core

Tuesday, November 29, 2011

Page 46: How to Install, Use, and Customize Drush

pm-updatecode (upc) Update Drupal core and contrib projects to latest recommended

releases

Tuesday, November 29, 2011

Page 47: How to Install, Use, and Customize Drush

updatedb (updb)Apply any database updates required

(as with running update.php).

Tuesday, November 29, 2011

Page 48: How to Install, Use, and Customize Drush

But  there’s  more!

Tuesday, November 29, 2011

Page 49: How to Install, Use, and Customize Drush

user-login (uli)Display a one time login link for

the given user account (defaults to uid 1).

Forget the password?

Tuesday, November 29, 2011

Page 51: How to Install, Use, and Customize Drush

sql-dumpExports the Drupal DB as SQL using

mysqldump or equivalent.

Moving the database?

Tuesday, November 29, 2011

Page 52: How to Install, Use, and Customize Drush

sql-dump > /backups/site-backup.sql

ssh user@host ‘drush sql-dump | gzip -’ |

gunzip - | mysql localdb

Tuesday, November 29, 2011

Page 53: How to Install, Use, and Customize Drush

variable-set (vset) Set a variable.

Tuesday, November 29, 2011

Page 54: How to Install, Use, and Customize Drush

drush vset maintenance_mode 1

Take the site offline

Tuesday, November 29, 2011

Page 55: How to Install, Use, and Customize Drush

watchdog-show (ws)Show watchdog messages.

Tuesday, November 29, 2011

Page 56: How to Install, Use, and Customize Drush

Aliases

Tuesday, November 29, 2011

Page 57: How to Install, Use, and Customize Drush

Aliases

• Used  to  run  drush  commands  from  anywhere.

• Syntax:  drush  @myalias  cc  all

• myalias  could  be  local,  or  remote.

• Stored  in  ~/.drush

Tuesday, November 29, 2011

Page 58: How to Install, Use, and Customize Drush

$aliases[jacobsingh.local] = array( 'uri' => jacobsingh.local, 'root' => '/Users/jacob/work/engineering/gardens/trunk/docroot',);

$aliases['training.test'] = array( 'root' => '/var/www/html/trainingstg/docroot', 'remote-host' => 'staging-9.network.hosting.acquia.com', 'remote-user' => 'training',);

Tuesday, November 29, 2011

Page 59: How to Install, Use, and Customize Drush

drush @jacobsingh.local cc all

Clears the cache on my local site

Tuesday, November 29, 2011

Page 60: How to Install, Use, and Customize Drush

drush @training.test cc all

SSH’s into the training site, clears the cache.

Tuesday, November 29, 2011

Page 61: How to Install, Use, and Customize Drush

But  there’s  more!

Tuesday, November 29, 2011

Page 62: How to Install, Use, and Customize Drush

Deployment

• drush  rsync

• drush  sql-­‐sync

• drush  site-­‐upgrade

• archive-­‐dump  |  archive-­‐restore

• test-­‐run

Tuesday, November 29, 2011

Page 63: How to Install, Use, and Customize Drush

Maintenance  

• search-­‐reindex

• image-­‐flush

• cache-­‐clear

• watchdog-­‐show

Tuesday, November 29, 2011

Page 64: How to Install, Use, and Customize Drush

Configuration  management

• features-­‐update

• features-­‐diff

• features-­‐revert

Tuesday, November 29, 2011

Page 65: How to Install, Use, and Customize Drush

User  management

• user-­‐add-­‐role

• user-­‐create

• user-­‐password

• user-­‐block

Tuesday, November 29, 2011

Page 66: How to Install, Use, and Customize Drush

Extendable

• 92  addons  available  on  Drupal.org

• Writing  extensions  is  pretty  easy!

• Examples:  ApacheSolr,  Backup  and  Migrate,  Coder,  Simpletest,  Views,  Devel  Generate.

Tuesday, November 29, 2011

Page 67: How to Install, Use, and Customize Drush

drush.ws

Tuesday, November 29, 2011