Upload
digital006
View
2.156
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
CUSTOM DRUSH COMMANDSHOW TO BUILD YOUR OWN CUSTOM DRUSH COMMANDS
Created by / Mike Bell @mikebell_
WHO?Mike BellTwitter - Drupal.org - Where - CTI Digital - Drupal Technical Architect
@mikebell_digital006
WHAT IS DRUSH?Command line utility for Drupal
Used by most Drupal developers, an insanely powerful tool
drupal.org/project/drush
ALIAS UPTHE PROBLEM:
Updating aliases across multiple multiple dev machineswithout 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.
CAVEATInsecure, Demo, Use at own risk!
THE TOOLSDrush...ComposerSymfony YAML
COMPOSERWHAT IS IT?
Dependency manager for PHP.
WHY?Used for grabbing Symfony components and creating an
autoloader for them.
COMPOSER EXAMPLE
{ "name": "drush/alias_up", "description": "Provide a method to automatically upgrade a user's aliases.drushrc.php using drush itself." "license": "GPL-2.0+", "require": { "symfony/yaml": "2.3.*" }}
SYMFONY/YAMLUsed for parsing Yaml files into arrays.
Also used in Drupal 8 core for all config files.
EXAMPLE CONFIG FILE
type: git (git/http/https)source: http://mikebell.io/alias.phpupdatefreq: 1 (days)
THE HOOKSSymfony Autoloadhook_drush_help()hook_drush_command()aliasup_init()aliasup()aliasup_download()hook_drush_init()aliasup_uninstall()
SYMFONY AUTOLOADAuto load the YAML component
require 'vendor/autoload.php'; use Symfony\Component\Yaml\Yaml;
HOOK_DRUSH_HELP()Define standard help for the command
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'));
INSTALL1. Clone Repository2. composer.phar install3. cp example.config.yml../aliasup.config.yml
4. Configure5. Create aliases.drush.php6. drush aui7. drush sa --table
USAGEdrush au
Updates the alias file from the remote server
UNINSTALLdrush auuni
Removes all the code from the install.
LIVE DEMOWhat could go wrong?
ANY QUESTIONS?
RESOURCES
Presentation resources:
- Used for presentation - HTML shorthand
Drush API FileDrupal Answers
Reveal.jsZen CodingReveal and Zen Coding Blog Post