Custom Drush Commands - Drupal Yorkshire
Upcoming SlideShare
Loading in...5
×
 

Custom Drush Commands - Drupal Yorkshire

on

  • 1,050 views

 

Statistics

Views

Total Views
1,050
Slideshare-icon Views on SlideShare
1,032
Embed Views
18

Actions

Likes
1
Downloads
2
Comments
0

1 Embed 18

https://twitter.com 18

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Custom Drush Commands - Drupal Yorkshire Custom Drush Commands - Drupal Yorkshire Presentation Transcript

    • CUSTOM DRUSH COMMANDS HOW TO BUILD YOUR OWN CUSTOM DRUSH COMMANDS Created by /Mike Bell @mikebell_
    • WHO? Mike Bell Twitter - 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 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.
    • CAVEAT Insecure, Demo, Use at own risk!
    • THE TOOLS Drush... Composer Symfony YAML
    • COMPOSER WHAT 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. "license": "GPL-2.0+", "require": { "symfony/yaml": "2.3.*" } }
    • SYMFONY/YAML Used 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.php updatefreq: 1 (days)
    • THE HOOKS Symfony Autoload hook_drush_help() hook_drush_command() aliasup_init() aliasup() aliasup_download() hook_drush_init() aliasup_uninstall()
    • SYMFONY AUTOLOAD Auto load the YAML component require 'vendor/autoload.php'; use SymfonyComponentYamlYaml;
    • 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') );
    • 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
    • USAGE drush au Updates the alias file from the remote server
    • UNINSTALL drush auuni Removes all the code from the install.
    • LIVE DEMO What could go wrong?
    • ANY QUESTIONS?
    • RESOURCES Presentation resources: - Used for presentation - HTML shorthand Drush API File Drupal Answers Reveal.js Zen Coding Reveal and Zen Coding Blog Post