Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Custom Drush Commands - Drupal Yorkshire

2,463 views

Published on

Published in: Technology
  • Be the first to comment

Custom Drush Commands - Drupal Yorkshire

  1. 1. CUSTOM DRUSH COMMANDS HOW TO BUILD YOUR OWN CUSTOM DRUSH COMMANDS Created by /Mike Bell @mikebell_
  2. 2. WHO? Mike Bell Twitter - Drupal.org - Where - CTI Digital - Drupal Technical Architect @mikebell_ digital006
  3. 3. WHAT IS DRUSH? Command line utility for Drupal Used by most Drupal developers, an insanely powerful tool drupal.org/project/drush
  4. 4. ALIAS UP THE PROBLEM: Updating aliases across multiple multiple dev machines without the user having to go out of their way. THE SOLUTION: Drush command to keep aliases in sync. Prompt user for download when using Drush.
  5. 5. CAVEAT Insecure, Demo, Use at own risk!
  6. 6. THE TOOLS Drush... Composer Symfony YAML
  7. 7. COMPOSER WHAT IS IT? Dependency manager for PHP. WHY? Used for grabbing Symfony components and creating an autoloader for them.
  8. 8. COMPOSER EXAMPLE { "name": "drush/alias_up", "description": "Provide a method to automatically upgrade a user's aliases. "license": "GPL-2.0+", "require": { "symfony/yaml": "2.3.*" } }
  9. 9. SYMFONY/YAML Used for parsing Yaml files into arrays. Also used in Drupal 8 core for all config files.
  10. 10. EXAMPLE CONFIG FILE type: git (git/http/https) source: http://mikebell.io/alias.php updatefreq: 1 (days)
  11. 11. THE HOOKS Symfony Autoload hook_drush_help() hook_drush_command() aliasup_init() aliasup() aliasup_download() hook_drush_init() aliasup_uninstall()
  12. 12. SYMFONY AUTOLOAD Auto load the YAML component require 'vendor/autoload.php'; use SymfonyComponentYamlYaml;
  13. 13. HOOK_DRUSH_HELP() Define standard help for the command
  14. 14. HOOK_DRUSH_COMMAND() Define your command and the short commands for running $items['aliasup'] = array( 'description' => 'Update aliases from central server', 'callback' => 'aliasup', 'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, 'examples' => array( 'drush aliasup' => 'Update aliases' ), 'aliases' => array('au') );
  15. 15. INSTALL 1. Clone Repository 2. composer.phar install 3. cp example.config.yml ../aliasup.config.yml 4. Configure 5. Create aliases.drush.php 6. drush aui 7. drush sa --table
  16. 16. USAGE drush au Updates the alias file from the remote server
  17. 17. UNINSTALL drush auuni Removes all the code from the install.
  18. 18. LIVE DEMO What could go wrong?
  19. 19. ANY QUESTIONS?
  20. 20. RESOURCES Presentation resources: - Used for presentation - HTML shorthand Drush API File Drupal Answers Reveal.js Zen Coding Reveal and Zen Coding Blog Post

×