Drush 9
Moshe Weitzman && Greg Anderson
Moshe Weitzman
Greg Anderson
“Drush is a veritable Swiss Army knife designed to make life easier for those who hack at the command prompt.”
About Drush 9
Using Drush9
Start new project
Migrate existing site
Familiar friends still kicking
Dearly departed
Departed for now
New friends
Generate code
Drush9 APIs
Command Authoring
| | |
| | |
| | |
| | |
Drush with Symfony Console
| Drush | Drupal CLI Tool - Bootstrap - Site Aliases - Remote Execution - |
| Robo | PHP Task Runner - Task Collections - |
| Consolidation | General-Purpose CLI Libraries - Annotations - Output Formatting - Configuration - |
| Symfony | PHP Framework Used by Drupal - Console - Process Execution - Filesystem Utilities - |
Two Autoloader Problem
Drush Preflight
Code Available During Preflight and Bootstrap
Identify Drupal Site
Load Drupal autoloader
Bootstrap Drupal
Drush sources
Drush vendor
Drupal vendor
Drupal sources
Drush sources
Drush vendor
Drupal vendor
Drupal sources
Drush sources
Drush vendor
Drupal vendor
Drupal sources
Safe code in use
Available code not yet loaded
Code in use that MIGHT conflict
Validate state
Execute
Process Tasks
Format output
@command
@hook
validate
Output formatters
Prepare
to run
Initialize variables
Prompt user
@hook
interact
Validate args & options
@hook
init
@hook
command-event
Bootstrap Sequence in $application->run()
Standard Drush Hooks
Command Event Hooks:
Init Hooks:
Output Formatter Data Preparation
/**
* @field-labels
* first: I
* second: II
* third: III
* @returns RowsOfFields
*/
public function tryFormatters($options = ['format' => 'table', 'fields' => ''])
{
$outputData = [
'en' => [ 'first' => 'One', 'second' => 'Two', 'third' => 'Three' ],
'de' => [ 'first' => 'Eins', 'second' => 'Zwei', 'third' => 'Drei' ],
'jp' => [ 'first' => 'Ichi', 'second' => 'Ni', 'third' => 'San' ],
'es' => [ 'first' => 'Uno', 'second' => 'Dos', 'third' => 'Tres' ],
];
return new RowsOfFields($outputData);
}
Output Format Selection
--format=table
--format=yaml
Output Field Selection
--fields=III,I
--fields=III,I --format=json
Drush Config Now .yml
drushrc.php |
$command_specific['site-install'] = array( 'account-name' => 'alice', 'account-pass' => 'secret' ); |
drush.yml |
command: site: install: options: account-name: alice account-pass: secret |
Drush Aliases are also .yml Config
aliases.drushrc.php: |
$aliases['anything.at.all.dev'] = array( 'root' => '/path/to/drupal', 'uri' => 'https://dev.example.com' ); |
example.alias.yml: |
dev: root: /path/to/drupal uri: ‘https://dev.example.com live: host: isp.com root: /srv/www/example uri: https://example.com |
Site Alias Groups
group.aliases.yml: |
site-one: dev: root: /path/to/drupal uri: ‘https://site-one.com site-two: dev: root: /path/to/drupal uri: ‘https://site-two.com |
Drush Tests
JOIN US FOR
CONTRIBUTION SPRINT
Friday, 29 September, 2017
First time
Sprinter Workshop
Mentored
Core Sprint
General Sprint
9:00-12:00
Room: Lehar 1 - Lehar 2
9:00-18:00
Room: Stolz 2
9:00-18:00
Room: Mall
#drupalsprints
WHAT DID YOU THINK?
Locate this session at the DrupalCon Vienna website:
http://vienna2017.drupal.org/schedule
Take the survey!
https://www.surveymonkey.com/r/drupalconvienna
Extra Art