34
drush a "quick" introduction

Drush

Embed Size (px)

DESCRIPTION

A "quick" introduction to drush, the Drupal command line tool.

Citation preview

Page 1: Drush

drusha "quick" introduction

Page 2: Drush

What is it?

The Drupal shell Allows interaction with a Drupal site via command line Easy to use Really useful (honest!)

Page 3: Drush

Installing

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

May have to run with sudo Might also have to run pear upgrade-all Can also use apt-get (might not be up to date)

Page 4: Drush

Installing

Windows Installer Available www.drush.org/drush_windows_installer Used to be almost unusable but appears to be better.

Page 5: Drush

Using Drush

Page 6: Drush

drush

Prints a list of available drush commands Good to see if you have installed it or not

Page 7: Drush

drush help <command>

Prints out help text for a command.

Page 8: Drush

drush status

Shows current status of a drupal site Or just the version of drush if no site is found

Page 9: Drush

drush pm-list

List currently installed modules and themes Use --status to filter the list by status. Example:drush pm-list --status=enabled

Page 10: Drush

drush pm-download <project>

Downloads projects from Drupal.org Includes projects, themes and even Drupal itself Use the --select to prompt for a certain release Can be shortened to "drush dl"

Page 11: Drush

drush pm-releases <project>

List the releases for a project Helpful when using pm-download

Page 12: Drush

drush site-install <profile>

Install a site from the command line. --account-name to set master user username--account-pass to set master user password--db-url to set database connection string Example:drush site-install minimal --account-name=admin --account-pass=admin --db-url=mysql://root:QWEqwe123@localhost/drupal7

Page 13: Drush

drush pm-enable <extension>

Enable a module or theme. Use --yes to assume "yes" to prompts Can be shortened to "drush en <extension>"

Page 14: Drush

Live Demo!Full site install from the command line

Page 15: Drush

drush pm-disable <extension>

Disable a module or theme. Can be shortened to "drush dis <extension>"

Page 16: Drush

drush pm-uninstall <extension>

Completely remove a module from Drupal Basically runs the uninstall hooks

Page 17: Drush

drush pm-updatecode <project>

Update the code of an project Use --security-only to only get security releases Updates the code only, use "drush updatedb" to also apply any database updates

Page 18: Drush

drush pm-update <project>

Updates a projects code and applies any database updates Same as running pm-updatecode and updatedb

Page 19: Drush

drush cache-clear all

Clear all caches Can use shortcut "drush cc all" Specify type of cache to clear or leave blank to prompt for one

Page 20: Drush

drush core-cron

Run the cron Can also use "drush cron"

Page 21: Drush

Interacting with search

drush search-index drush search-reindex drush search-status Note: Need to have search module enabled!

Page 22: Drush

Interacting with users

drush user-block username drush user-unblock username drush user-password username --password=password drush user-information username

Page 23: Drush

Interacting with the database

drush sql-drop drush sql-dump --result-file=../mysite.sql drush sql-query --file=../mysite.sql

Page 24: Drush

...and many more

Barely scratched the surface here *Lots* more commands and flags available For a full list see: http://www.drush.org/help/5

Page 25: Drush

Drush Make

Page 26: Drush

Drush Make

Sort of like install profiles Single subject in itself Uses a 'make' file to download all needed modules Makes version control easier

Page 27: Drush

drush make-generate <makefile>

Generate a make file from an existing Drupal install No need to know the make file syntax inside and out Example:drush make-generate mysite.make

Page 28: Drush

Example Make File; This file was auto-generated by drush makecore = 7.x api = 2projects[drupal][version] = "7.x" ; Modulesprojects[ctools][version] = "1.0" projects[devel][version] = "1.2" projects[google_analytics][version] = "1.2" projects[views][version] = "3.3"

Page 29: Drush

drush make <makefile>

Make a drush site using a make file Example:drush make mysite.make

Page 30: Drush

MOAR!!!I can haz moar commands?

Page 31: Drush

Drush API

Drush has an API and so modules can plug in to drush and allow additional commands Reference site:http://api.drush.org/api/drush

Page 32: Drush

Views

Interact with views from Drush drush views-list drush views-enable <view> drush views-disable <view>

Page 33: Drush

Devel Generate

Adds devel generate support for drush Create 10 nodes:drush generate-content 10 Create 10 nodes, with 5 (or less) comments:drush generate-content 10 5 (Make sure comment is enabled!)

Page 34: Drush

Resources

Drush Project Pagewww.drupal.org/project/drush Main Drush Sitewww.drush.org Drush APIapi.drush.org/api/drush