Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
SlideShare a Scribd company logo
drush
a "quick" introduction
What is it?
The Drupal shell

Allows interaction with a Drupal site via
command line

Easy to use

Really useful (honest!)
Installing
Linux/OSX
   pear channel-discover pear.drush.org
   pear 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)
Installing
Windows

Installer Available

www.drush.org/drush_windows_installer

Used to be almost unusable but appears to be
better.
Using Drush
drush

Prints a list of available drush commands

Good to see if you have installed it or not
drush help <command>

Prints out help text for a command.
drush status

Shows current status of a drupal site

Or just the version of drush if no site is found
drush pm-list
List currently installed modules and themes

Use --status to filter the list by status.

Example:
drush pm-list --status=enabled
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"
drush pm-releases <project>
List the releases for a project

Helpful when using pm-download
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
drush pm-enable <extension>
Enable a module or theme.

Use --yes to assume "yes" to prompts

Can be shortened to "drush en <extension>"
Live Demo!
Full site install from the command line
drush pm-disable <extension>
Disable a module or theme.

Can be shortened to "drush dis <extension>"
drush pm-uninstall <extension>
Completely remove a module from Drupal

Basically runs the uninstall hooks
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
drush pm-update <project>
Updates a projects code and applies any
database updates

Same as running pm-updatecode and
updatedb
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
drush core-cron
Run the cron

Can also use "drush cron"
Interacting with search
drush search-index

drush search-reindex

drush search-status

Note: Need to have search module enabled!
Interacting with users
drush user-block username

drush user-unblock username

drush user-password username --
password=password

drush user-information username
Interacting with the database
drush sql-drop

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

drush sql-query --file=../mysite.sql
...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
Drush Make
Drush Make
Sort of like install profiles

Single subject in itself

Uses a 'make' file to download all needed
modules

Makes version control easier
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
Example Make File
; This file was auto-generated by drush make
core = 7.x

api = 2
projects[drupal][version] = "7.x"

; Modules
projects[ctools][version] = "1.0"

projects[devel][version] = "1.2"

projects[google_analytics][version] = "1.2"

projects[views][version] = "3.3"
drush make <makefile>
Make a drush site using a make file

Example:
drush make mysite.make
MOAR!!!
I can haz moar commands?
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
Views
Interact with views from Drush

drush views-list

drush views-enable <view>

drush views-disable <view>
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!)
Resources
Drush Project Page
www.drupal.org/project/drush

Main Drush Site
www.drush.org

Drush API
api.drush.org/api/drush

More Related Content

Drush