Intro to Drush• Who is it for?• What is it?• Why should you use it?• When should you use it?• How do you use it?
What is Drush?
What is Drush?A command line interface for managing       your Drupal website.
What is Drush?A command line interface for managing       your Drupal website.            $ drush cc
Do I really need it?
Do I really need it?• No. But you REALLY want it!
Do I really need it?• No. But you REALLY want it!• Useful during development process
Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites
Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites...
Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites...
What Can Drush Do For        Me?
What Can Drush Do For        Me?• Work with Drupal Core
What Can Drush Do For        Me?• Work with Drupal Core• Work with Fields (D7)
What Can Drush Do For        Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules
What Can Drush Do For        Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules• Work with Datab...
What Can Drush Do For        Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules• Work with Datab...
•Work with Drupal Core         Clear Cache        $ drush cc
•Work with Drupal Core          Run Cron        $ drush cron
•Work with Drupal Core       Run update.php        $ drush updb
•Work with Drupal Core    Empty watchdog (log) table        $ drush wd-del
•Work with Drupal Core    Empty watchdog (log) table        $ drush wd-del   $ drush wd-del --type=cron
•Work with Drupal Core     Index content for search     $ drush search-index     $ drush search-reindex
•Work with Drupal Core    update core minor (7.1→7.2)            $ drush up
•Work with Drupal Core    update core minor (7.1→7.2)            $ drush up    update core major (6.x→7.x)           $ dru...
•Work with Drupal Core           run tests    $ drush test-run --all
•Work with Drupal Core      Install Drupal (D7)
•Work with Drupal Core                    Install Drupal (D7)$ drush si --db-url=mysql://root:pass@localhost/port/dbname -...
•Work with Drupal Core      Status & Being Nosy          $ drush st     $ drush search-status         $ drush vget
•Work with Fields (D7)    Clone, Create, Delete, Get Info   $ drush field-create article  $ drush field-clone tags labels ...
•Work with Modules           Download   $ drush dl cck views token
•Work with Modules            enable / disable$ drush en content text views views_ui$ drush dis content text views views_ui
•Work with Modules         update        $ drush up
•Work with Modules          update         $ drush up             =        $ drush upc             +        $ drush updb
•Work with Modules   status (enabled/disabled/ver.)         $ drush pm-list
•Work with your Database TIP: make sure mysql command exists            $ mysql -uroot -p
•Work with your Database                execute queries $ drush sql-query “SELECT * FROM {users} WHERE uid=1”
•Work with your Database    export DB as SQL (mysqldump)  $ drush sql-dump --result-file=../06_15_2012.sql
•Work with your Database    drop (YIKES! BE CAREFUL!)        $ drush sql-drop
•Work with your Database    sync (rsync copy and import)   $ drush sql-sync @prod @stage
•Work with your Users                         Create Users$ drush ucrt dustyb --mail=”dusty@sacdrupal.com” --password=”abc...
•Work with your Users  Cancel Users (anonymizes content)        $ drush ucan dustyb
•Work with your Users          Block Users      $ drush ublk dustyb         Unblock Users      $ drush uublk dustyb
•Work with your Users         Add Role to User   $ drush urol “admin” dustyb      Remove Role from User   $ drush urrol “a...
•Work with your Users           Reset User’s Password$ drush upwd dustyb --password=”t&ur@tles”
•Work with your Users         Get User Info      $ drush uinf dustyb
What Drush Doesn’t       Do
What Drush Doesn’t       Do  Anything with your content!
Do Even More...
Do Even More...• Devel Module• Backup and Migrate• Views Bulk Operations• XML Sitemap• Node Export• Apache Solr Search Int...
Do Even More...
Drush Aliases aliases.drushrc.php
Drush Aliases             aliases.drushrc.php$aliases[example_stage] = array(   uri => staging.example.com,   root => /var...
Drush Aliases             aliases.drushrc.php$aliases[example_stage] = array(   uri => staging.example.com,   root => /var...
Drush Aliases             aliases.drushrc.php$aliases[example_stage] = array(   uri => staging.example.com,   root => /var...
Drush Make
Drush Make$ drush make example.makeexample
Drush Make        $ drush make example.make        example• Extension to Drush
Drush Make        $ drush make example.make        example• Extension to Drush• Prepares your site for installation
Drush Make        $ drush make example.make        example• Extension to Drush• Prepares your site for installation• Creat...
Drush Make        $ drush make example.make        example• Extension to Drush• Prepares your site for installation• Creat...
Installation Profiles
Installation Profiles      $ drush si example
Installation Profiles             $ drush si example• Works and set up like a module
Installation Profiles             $ drush si example• Works and set up like a module• Allows you to script custom  installa...
Drush Installation• Download http://drupal.org/project/  drush• Follow Installation Instructions in  README.txt
Sorry Windows Users...
Sorry Windows Users...     No Drush for you!!!
Other Install Options• Drupal Quickstart Project • drupal.org/project/quickstart • Pre-packaged PHP/LAMP    development en...
Other Install Options• Cygwin (http://www.cygwin.com/) • Makes Windows kind of act like   Linux • will have to set up a co...
Other Install Options• WebEnabled (webenabled.com) • web-based development   environment • Drush pre-installed • Also have...
Other Install Options• Acquia Dev Cloud (acquia.com) • web-based development   environment • Drush pre-installed • full de...
Other Install Options• Pantheon (getpantheon.com) • web-based development   environment • Drush pre-installed • full dev-s...
Other Install Options• Your Hosting • Must have shell access! • You will have to install
Other Install Options• Get a Mac! ;-)• Dual-boot Linux• Install Linux
Resources• http://drush.ws - full documentation• http://drupal.org/project/drush• http://nuvole.org/blog/drush - check  ou...
Thank Youcarsonblack.com
Intro to Drush
Upcoming SlideShare
Loading in...5
×

Intro to Drush

7,451

Published on

An introduction to the the who, what, why when and how of Drush, the command line utility for Drupal. Presentation given at the Sacramento Drupal Users Group meeting on 6/15/2011

Published in: Technology
1 Comment
3 Likes
Statistics
Notes
No Downloads
Views
Total Views
7,451
On Slideshare
0
From Embeds
0
Number of Embeds
9
Actions
Shares
0
Downloads
0
Comments
1
Likes
3
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • USERS is last\nOn to more detail...\n
  • USERS is last\nOn to more detail...\n
  • USERS is last\nOn to more detail...\n
  • USERS is last\nOn to more detail...\n
  • USERS is last\nOn to more detail...\n
  • \n
  • \n
  • \n
  • 2 commands shown here! + extra flag \n
  • \n
  • BUILD: Minor and Major update shown\n
  • \n
  • BUILD: types it out\n
  • st = Drupal version, Site URI, Database driver, Database hostname, Database username, Database name, Default theme, Administration theme, PHP configuration, Drush version, Drush configuration, Drush alias files, Drupal root, Site path, File directory path\n\nvget = dump all vars decently formatted arrays, or for specific var\n\nWORKING WITH FIELDS NEXT\n
  • field-create: arg is the content type then there is a dialog of choices for the field\nfield-info: kind of broken\n\nWORKING WITH MODULES NEXT\n
  • \n
  • \n
  • BUILD: update-code + update.php\n
  • can also use sm but it will give deprecated warning\ntip: grep for particular module\n\nWORKING WITH DATABASE NEXT\n
  • \n
  • \n
  • \n
  • drop all tables\n
  • NEXT: WORKING WITH USERS\n
  • \n
  • anonymizes content this person authored\n
  • TIP: can use uid, name, email\n
  • \n
  • \n
  • Returns: uid, name, mail, roles, status\n\nNEXT: WHAT IT DOESN’T DO\n
  • BUILD: anything with content - Create, edit, delete nodes\n\nNEXT: DO MORE - MODULES\n
  • BUILD: list of modules\n
  • NEXT: DRUSH ALIASES\n
  • BUILD: 1) alias config 2) enable token 3) sql-sync\n\nNEXT: DRUSH MAKE\n
  • BUILD: 1) alias config 2) enable token 3) sql-sync\n\nNEXT: DRUSH MAKE\n
  • BUILD: 1) alias config 2) enable token 3) sql-sync\n\nNEXT: DRUSH MAKE\n
  • BUILD: 1) example\n2) Extension\n3) prepares site\n4) single text file\n5) automates\nNEXT: INSTALL PROFILES\n
  • BUILD: 1) example\n2) Extension\n3) prepares site\n4) single text file\n5) automates\nNEXT: INSTALL PROFILES\n
  • BUILD: 1) example\n2) Extension\n3) prepares site\n4) single text file\n5) automates\nNEXT: INSTALL PROFILES\n
  • BUILD: 1) example\n2) Extension\n3) prepares site\n4) single text file\n5) automates\nNEXT: INSTALL PROFILES\n
  • BUILD: 1) example\n2) Extension\n3) prepares site\n4) single text file\n5) automates\nNEXT: INSTALL PROFILES\n
  • BUILD: 1) example\n2) works like module\n3) script custom install\n\nNEXT: INSTALLATION\n
  • BUILD: 1) example\n2) works like module\n3) script custom install\n\nNEXT: INSTALLATION\n
  • BUILD: 1) example\n2) works like module\n3) script custom install\n\nNEXT: INSTALLATION\n
  • NEXT: SORRY WINDOWS USERS...\n
  • BUILD: NO DRUSH FOR YOU\n\nNEXT: OTHER INSTALL OPTIONS\n
  • Download using bittorrent\n\nVirtual Machine - needs RAM\n\n
  • A bit of a hassle to get going. Ask GaryB\n
  • \n
  • \n
  • \n
  • \n
  • NEXT: Resources\n
  • NEXT: FIN\n
  • \n
  • Intro to Drush

    1. 1. Intro to Drush• Who is it for?• What is it?• Why should you use it?• When should you use it?• How do you use it?
    2. 2. What is Drush?
    3. 3. What is Drush?A command line interface for managing your Drupal website.
    4. 4. What is Drush?A command line interface for managing your Drupal website. $ drush cc
    5. 5. Do I really need it?
    6. 6. Do I really need it?• No. But you REALLY want it!
    7. 7. Do I really need it?• No. But you REALLY want it!• Useful during development process
    8. 8. Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites
    9. 9. Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites• +1 Drupal Street Cred...
    10. 10. Do I really need it?• No. But you REALLY want it!• Useful during development process• For those maintaining multiple sites• +1 Drupal Street Cred...• (you look like a real smartypants)
    11. 11. What Can Drush Do For Me?
    12. 12. What Can Drush Do For Me?• Work with Drupal Core
    13. 13. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)
    14. 14. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules
    15. 15. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules• Work with Database
    16. 16. What Can Drush Do For Me?• Work with Drupal Core• Work with Fields (D7)• Work with Contrib Modules• Work with Database• Work with Users
    17. 17. •Work with Drupal Core Clear Cache $ drush cc
    18. 18. •Work with Drupal Core Run Cron $ drush cron
    19. 19. •Work with Drupal Core Run update.php $ drush updb
    20. 20. •Work with Drupal Core Empty watchdog (log) table $ drush wd-del
    21. 21. •Work with Drupal Core Empty watchdog (log) table $ drush wd-del $ drush wd-del --type=cron
    22. 22. •Work with Drupal Core Index content for search $ drush search-index $ drush search-reindex
    23. 23. •Work with Drupal Core update core minor (7.1→7.2) $ drush up
    24. 24. •Work with Drupal Core update core minor (7.1→7.2) $ drush up update core major (6.x→7.x) $ drush sup
    25. 25. •Work with Drupal Core run tests $ drush test-run --all
    26. 26. •Work with Drupal Core Install Drupal (D7)
    27. 27. •Work with Drupal Core Install Drupal (D7)$ drush si --db-url=mysql://root:pass@localhost/port/dbname --account-pass=abc123 --account-mail=admin@example.com --site-name=My Site
    28. 28. •Work with Drupal Core Status & Being Nosy $ drush st $ drush search-status $ drush vget
    29. 29. •Work with Fields (D7) Clone, Create, Delete, Get Info $ drush field-create article $ drush field-clone tags labels $ drush field-delete article $ drush field-info article
    30. 30. •Work with Modules Download $ drush dl cck views token
    31. 31. •Work with Modules enable / disable$ drush en content text views views_ui$ drush dis content text views views_ui
    32. 32. •Work with Modules update $ drush up
    33. 33. •Work with Modules update $ drush up = $ drush upc + $ drush updb
    34. 34. •Work with Modules status (enabled/disabled/ver.) $ drush pm-list
    35. 35. •Work with your Database TIP: make sure mysql command exists $ mysql -uroot -p
    36. 36. •Work with your Database execute queries $ drush sql-query “SELECT * FROM {users} WHERE uid=1”
    37. 37. •Work with your Database export DB as SQL (mysqldump) $ drush sql-dump --result-file=../06_15_2012.sql
    38. 38. •Work with your Database drop (YIKES! BE CAREFUL!) $ drush sql-drop
    39. 39. •Work with your Database sync (rsync copy and import) $ drush sql-sync @prod @stage
    40. 40. •Work with your Users Create Users$ drush ucrt dustyb --mail=”dusty@sacdrupal.com” --password=”abc123”
    41. 41. •Work with your Users Cancel Users (anonymizes content) $ drush ucan dustyb
    42. 42. •Work with your Users Block Users $ drush ublk dustyb Unblock Users $ drush uublk dustyb
    43. 43. •Work with your Users Add Role to User $ drush urol “admin” dustyb Remove Role from User $ drush urrol “admin” dustyb
    44. 44. •Work with your Users Reset User’s Password$ drush upwd dustyb --password=”t&ur@tles”
    45. 45. •Work with your Users Get User Info $ drush uinf dustyb
    46. 46. What Drush Doesn’t Do
    47. 47. What Drush Doesn’t Do Anything with your content!
    48. 48. Do Even More...
    49. 49. Do Even More...• Devel Module• Backup and Migrate• Views Bulk Operations• XML Sitemap• Node Export• Apache Solr Search Integration• Module Builder• Coder• Features, Views and CTools• Many more....
    50. 50. Do Even More...
    51. 51. Drush Aliases aliases.drushrc.php
    52. 52. Drush Aliases aliases.drushrc.php$aliases[example_stage] = array( uri => staging.example.com, root => /var/www/stage_example, db-url => mysqli://root:pass@localhost/example_stage,);$aliases[example_prod] = array( uri => www.example.com, root => /var/www/example, db-url => mysqli://root:pass@localhost/example_prod, remote-host => 192.232.232.33’, remote-user => carsonbl’,);
    53. 53. Drush Aliases aliases.drushrc.php$aliases[example_stage] = array( uri => staging.example.com, root => /var/www/stage_example, db-url => mysqli://root:pass@localhost/example_stage,);$aliases[example_prod] = array( uri => www.example.com, root => /var/www/example, db-url => mysqli://root:pass@localhost/example_prod, remote-host => 192.232.232.33’, remote-user => carsonbl’,); $ drush @example_stage en token
    54. 54. Drush Aliases aliases.drushrc.php$aliases[example_stage] = array( uri => staging.example.com, root => /var/www/stage_example, db-url => mysqli://root:pass@localhost/example_stage,);$aliases[example_prod] = array( uri => www.example.com, root => /var/www/example, db-url => mysqli://root:pass@localhost/example_prod, remote-host => 192.232.232.33’, remote-user => carsonbl’,); $ drush @example_stage en token $ drush sql-sync @example_prod @example_stage
    55. 55. Drush Make
    56. 56. Drush Make$ drush make example.makeexample
    57. 57. Drush Make $ drush make example.make example• Extension to Drush
    58. 58. Drush Make $ drush make example.make example• Extension to Drush• Prepares your site for installation
    59. 59. Drush Make $ drush make example.make example• Extension to Drush• Prepares your site for installation• Create complicated Drupal distribution using a single text file
    60. 60. Drush Make $ drush make example.make example• Extension to Drush• Prepares your site for installation• Create complicated Drupal distribution using a single text file• Automates download of core, modules, patches, external libraries and external code from repos
    61. 61. Installation Profiles
    62. 62. Installation Profiles $ drush si example
    63. 63. Installation Profiles $ drush si example• Works and set up like a module
    64. 64. Installation Profiles $ drush si example• Works and set up like a module• Allows you to script custom installation process
    65. 65. Drush Installation• Download http://drupal.org/project/ drush• Follow Installation Instructions in README.txt
    66. 66. Sorry Windows Users...
    67. 67. Sorry Windows Users... No Drush for you!!!
    68. 68. Other Install Options• Drupal Quickstart Project • drupal.org/project/quickstart • Pre-packaged PHP/LAMP development environment (Ubuntu) • Drush is pre-installed and ready to go!
    69. 69. Other Install Options• Cygwin (http://www.cygwin.com/) • Makes Windows kind of act like Linux • will have to set up a complete development environment
    70. 70. Other Install Options• WebEnabled (webenabled.com) • web-based development environment • Drush pre-installed • Also have simplistic web app in control panel to do drush visually • Free development environments!
    71. 71. Other Install Options• Acquia Dev Cloud (acquia.com) • web-based development environment • Drush pre-installed • full dev-stage-prod hosting environment • $149 /mo.
    72. 72. Other Install Options• Pantheon (getpantheon.com) • web-based development environment • Drush pre-installed • full dev-stage-prod hosting environment • aliases for each environment configured
    73. 73. Other Install Options• Your Hosting • Must have shell access! • You will have to install
    74. 74. Other Install Options• Get a Mac! ;-)• Dual-boot Linux• Install Linux
    75. 75. Resources• http://drush.ws - full documentation• http://drupal.org/project/drush• http://nuvole.org/blog/drush - check out the shortcuts• http://drupal.org/project/drush_make
    76. 76. Thank Youcarsonblack.com

    ×