Drush: The essential Drupal tool Tuesday, November 29, 2011
Jan 28, 2015
Drush: The essential Drupal tool
Tuesday, November 29, 2011
@JacobSingh
Trainer Engineer Speaker
About me
http://jacobsingh.name
Tuesday, November 29, 2011
@JacobSingh
Lover Fighter Whiskers
About movember
HTTP://TINYURL.COM/JACOBMO
Tuesday, November 29, 2011
What do programmers hate more than
anything?
Tuesday, November 29, 2011
Work that is
Tuesday, November 29, 2011
Tedious
Tuesday, November 29, 2011
& Repetitive
Tuesday, November 29, 2011
Introducing
Tuesday, November 29, 2011
Drush!
Tuesday, November 29, 2011
Drupal + shell
Tuesday, November 29, 2011
What the shell?
Tuesday, November 29, 2011
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
Tuesday, November 29, 2011
Exercise: Open the shell
Tuesday, November 29, 2011
Windows
• Click on Start
• Type “cmd” into the program search
• Hit enter to select the command prompt
Tuesday, November 29, 2011
OSX
• Go to Applications -‐> Utilities
• Click on terminal
Tuesday, November 29, 2011
Exercise: Installing Drush
Tuesday, November 29, 2011
pear channel-discover pear.drush.orgpear install drush/drush
* Windows is a little different. See http://drush.ws
Tuesday, November 29, 2011
Why Drush?
• Speed
• Automation
Tuesday, November 29, 2011
Drush can do a lot of things
Tuesday, November 29, 2011
command (cmd)description.
Tuesday, November 29, 2011
Let’s try a few
Tuesday, November 29, 2011
cache-clear (cc) Clear a specific cache, or all
drupal caches.
Tuesday, November 29, 2011
Exercise: Download Drupal
Tuesday, November 29, 2011
pm-download (dl) Download projects from drupal.org or
other sources.
Tuesday, November 29, 2011
Downloading Drupal
dl drupalDrush
Tuesday, November 29, 2011
Exercise: Install Drupal
Tuesday, November 29, 2011
Tuesday, November 29, 2011
site-install (si) Install Drupal along with modules/
themes/configuration using the specified install profile.
Tuesday, November 29, 2011
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
Pass --db-url option
Tuesday, November 29, 2011
Pass --db-url option.
Tuesday, November 29, 2011
Drush command Structure
Command Options Arguments
Tuesday, November 29, 2011
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
Most important option!!!!
Tuesday, November 29, 2011
--help
Tuesday, November 29, 2011
--helpsite-installLists all of the options and arguments for the site-
install command. Also provides examples.
Tuesday, November 29, 2011
Exercise: Adding modules
Tuesday, November 29, 2011
Download views
dl viewsDrush
Tuesday, November 29, 2011
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
Exercise: Enabling modules
Tuesday, November 29, 2011
pm-enable (en) Enable one or more extensions
(modules or themes).
Tuesday, November 29, 2011
Enable views
en views views_uiDrush
Tuesday, November 29, 2011
Any questions before we continue?
Tuesday, November 29, 2011
Updating modules
dl webform-7.x-3.11Drush
upc webformDrush
updatedbDrush
en webformDrush
--no-core
Tuesday, November 29, 2011
pm-updatecode (upc) Update Drupal core and contrib projects to latest recommended
releases
Tuesday, November 29, 2011
updatedb (updb)Apply any database updates required
(as with running update.php).
Tuesday, November 29, 2011
But there’s more!
Tuesday, November 29, 2011
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
$ drush ulihttp://localhost/?q=user/reset/
1/1322445074/5wbzEG1jyjNZpbVRIasOjYaXvsY3cuu9TK0ZaRsrk2Q
Tuesday, November 29, 2011
sql-dumpExports the Drupal DB as SQL using
mysqldump or equivalent.
Moving the database?
Tuesday, November 29, 2011
sql-dump > /backups/site-backup.sql
ssh user@host ‘drush sql-dump | gzip -’ |
gunzip - | mysql localdb
Tuesday, November 29, 2011
variable-set (vset) Set a variable.
Tuesday, November 29, 2011
drush vset maintenance_mode 1
Take the site offline
Tuesday, November 29, 2011
watchdog-show (ws)Show watchdog messages.
Tuesday, November 29, 2011
Aliases
Tuesday, November 29, 2011
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
$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
drush @jacobsingh.local cc all
Clears the cache on my local site
Tuesday, November 29, 2011
drush @training.test cc all
SSH’s into the training site, clears the cache.
Tuesday, November 29, 2011
But there’s more!
Tuesday, November 29, 2011
Deployment
• drush rsync
• drush sql-‐sync
• drush site-‐upgrade
• archive-‐dump | archive-‐restore
• test-‐run
Tuesday, November 29, 2011
Maintenance
• search-‐reindex
• image-‐flush
• cache-‐clear
• watchdog-‐show
Tuesday, November 29, 2011
Configuration management
• features-‐update
• features-‐diff
• features-‐revert
Tuesday, November 29, 2011
User management
• user-‐add-‐role
• user-‐create
• user-‐password
• user-‐block
Tuesday, November 29, 2011
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
drush.ws
Tuesday, November 29, 2011