Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Sergei Stryukov.Drush.Why it should be used.DrupalCamp Kyiv 2011

  1. 1. Drush.Why should it be used?
  2. 2. Gold Sponsor ofDrupalCamp Kyiv 2011
  3. 3. Silver Sponsors ofDrupalCamp Kyiv 2011
  4. 4. What will be described?1. Drush. What is this? Common information.2. What features does Drush have “from the box”?3. Features which Drush may have with extensions.4. Examples of how Drush helps during development process.
  5. 5. What wont be described?1. Aliases of sites.2. Synchronization of code and databases.3. Development of extensions.4. Upgrade of Drupal code, modules and themes.5. Many other helpful Drush commands and features which I dont know about.
  6. 6. Part 1Common information.
  7. 7. Common information1. Drush == drupal shell == command line.2. Installation of Drush – README helps us!3. Whats next? Ask Drush to show you what it can to do!4. So many commands, how could I use them? Ask Help for help!5. How to use commands? Its simple: «drush [options] [command]»
  8. 8. First Drush responseExecute a drush command. Run `drush help [command]` to view commandspecific help. Run `drush topic` to read even more documentation.Global options (see `drush topic core-global-options` for the full list): …options…Core drush commands: (core) …commands…Field commands: (field) …commands…SQL commands: (sql) …commands…User commands: (user) …commands…
  9. 9. Help messagess81@laptop:~$ drush help ccClear a specific cache, or all drupal caches.Arguments:type The particular cache to clear. Omit this argument to choose from available caches.Aliases: cc
  10. 10. Clear cache and enable moduless81@laptop:~$ drush cc allall cache was cleared [success]ss81@laptop:~$ drush en -y forumThe following extensions will be enabled: taxonomy, forumDo you really want to continue? (y/n): yforum was enabled successfully. [ok]taxonomy was enabled successfully. [ok]
  11. 11. Part 2Extend Drush features with other modules.
  12. 12. Groups of commands1. Core rush commands (28 commands).2. Field commands (5 commands).3. Project manager commands (11 commands).4. SQL commands (6 commands).5. User commands (9 commands). TOTAL: 59.
  13. 13. Modules, which I like1. Devel.2. Drush Make.3. Module Builder.4. Drush Cleanup.5. Backup and Migrate.
  14. 14. DevelAll commands in devel: (devel) … devel-reinstall (dre) Disable, Uninstall, and Install a list of projects.... fn-view (fnv) Show the source of specified function or method.All commands in devel_generate: (devel_generate) generate-content (genc) Create content....
  15. 15. Drush Make1. Projects: drupal, pressflow, modules, themes. Could be downloaded from repository, by direct link, by name.2. Libraries: any files you need to use.
  16. 16. Example of Drush Make fileprojects[] = drupalprojects[] = apachesolr…libraries[SolrPhpClient][download][type] = "get"libraries[SolrPhpClient][download][url] = "http://solr-php-"libraries[SolrPhpClient][destination] = "modules/apachesolr"
  17. 17. Module BuilderExamples:drush mb my_module menu cron nodeapidrush mb my_module menu cron --write --name="My module" --dep="forum views"drush mb my_module menu cron --add
  18. 18. Backup and MigrateAll commands in backup_migrate: (backup_migrate)bam-backup (bb) Backup the sites database with Backup and Migrate.bam-backups Get a list of previously created backup files.bam-destinations Get a list of available destinations.bam-profiles Get a list of available settings profiles.bam-restore Restore the sites database with Backup and Migrate.bam-sources Get a list of available sources.
  19. 19. Part 3How Drush helps during development process.
  20. 20. Base facts1. Site URL is Version of Drupal – 7.3. Additional modules: admin_menu, pathauto, views.4. Custom modules: one module with some features will be created. It will use database.PS: no Drush Make because its not interesting.
  21. 21. Step 1ss81@laptop:~/session$ drush dl drupalProject drupal (7.2) downloaded to /home/ss81/session/drupal-7.2. [success]Project drupal contains: [success]- 3 profiles: minimal, testing, standard- 4 themes: bartik, seven, garland, stark- 47 modules: drupal_system_listing_compatible_test, ...
  22. 22. Step 2ss81@laptop:~/session$ mv drupal-7.2/* ./ss81@laptop:~/session$ mv drupal-7.2/.htaccess ./ss81@laptop:~/session$ lsauthorize.php cron.php index.php install.php LICENSE.txt modules robots.txt themes web.configCHANGELOG.txt drupal-7.2 INSTALL.mysql.txt…ss81@laptop:~/session$ rm -r drupal-7.2/
  23. 23. Step 3ss81@laptop:~/session$ drush si--db-url=mysql://root:111@localhost/session--account-name=ss81 --account-pass=qwertyYou are about to create a sites/default/files directory and createa sites/default/settings.php file and DROP your session databaseand then CREATE a new one. Do you want to continue? (y/n): yStarting Drupal installation. This takes a few seconds ... [ok]
  24. 24. Step 4ss81@laptop:~/session$ drush dl admin_menu views pathauto token…ss81@laptop:~/session$ drush en -y admin_menu views pathauto tokenThe following projects have unmet dependencies:views requires ctoolsWould you like to download them? (y/n): yProject ctools (7.x-1.0-alpha4) downloaded to /home/ss81/session/sites/all/modules/ctools. [success]... Thats all. We installed a site! Lets create a custom module.
  25. 25. Step 5ss81@laptop:~/session$ drush mbdlHook files have been downloaded to public://hooks and processed.We need to download hooks definitions before we can generate a module. There are 33 files with different hooks, so this could be used as a good manual.
  26. 26. Step 6ss81@laptop:~/session$ drush mb my_module menu permissionuser_load --write --name="My module" --desc="My test module“--pachage="test" --noiProposed my_module.module:…code of the module...Proposed…code of the info file...
  27. 27. Helpful commandsdrush dre -y my_moduledrush sql-dump > dump.sqldrush -y sql-dropdrush -y sql-cli < dump.sqldrush cc alldrush scr test.php
  28. 28. Helpful links
  29. 29. QuestionsEmail: sergei@powerfulcms.comSkype: sergei.stryukovDrupal: