SlideShare a Scribd company logo
1 of 32
Download to read offline
Drush in the Composer Era
1Photo © 2012 by Charlie Nguyen, CC BY 2.0
2
Overview
Using Composer Dependency Hell Site-Local Drush
Configuration Filter The FutureDrush Extensions
It is now possible to use Composer to
add code directly to Drupal:
drush dl drupal-8
cd drupal-8
composer require drupal/og:8.*
composer update will not update
drupal/core; use drush pm-update
drupal for this.
3
Standard Composer used in D8
web
├── autoload.php
├── composer.json
├── core
│ └─ composer.json
├── index.php
└── vendor
└─ autoload.php
4
wikimedia/composer-merge-plugin
{
"name": "drupal/drupal",
"require": {
"composer/installers": "^1.0.21",
"wikimedia/composer-merge-plugin": "^1.3.0"
},
"extra": {
"_readme": [
"By default Drupal loads the autoloader from ./vendor/autoload.php.",
"To change the autoloader you can edit ./autoload.php."
],
"merge-plugin": {
"include": [
"core/composer.json"
],
"recurse": false,
"replace": false,
"merge-extra": false
}
},
}
Uses “split core” to manage Drupal
core files:
composer create-project drupal-
composer/drupal-project:8.x-dev
my-site-name --stability dev --
no-interaction
5
Drupal 8: “drupal-project”
project
├── composer.json
├── vendor
│ └── autoload.php
└── web
├── autoload.php
├── core
│ └── composer.json
└── index.php
6
drupal-project Layout
{
"name": "drupal-composer/drupal-project",
"repositories": [
{
"type": "composer",
"url": "https://packagist.drupal-composer.org"
}
],
"require": {
"composer/installers": "^1.0.20",
"drupal/core": "8.0.*",
"drush/drush": "dev-master",
"drupal/console": "dev-master"
},
"extra": {
"installer-paths": {
"web/core": ["type:drupal-core"],
"web/modules/contrib/{$name}": ["type:drupal-module"],
"drush/contrib/{$name}": ["type:drupal-drush"]
}
}
}
7
Drupal 7: Example CI Scripts
example-drupal7-circle-composer
example-drupal7-travis-composer
CI
+
+
Use craychee/rootcanal to post-
process your Composer install:
"config": {
"bin-dir": "bin"
},
"scripts": {
"post-install-cmd": [
"bin/rootcanal"
],
"post-update-cmd": [
"bin/rootcanal"
]
}
}
http://craychee.io/blog/2015/08/01/no-excuses-part3-composer/ 8
Drupal 7: rootcanal
Dependency Hell
9
The Multiple Autoloaders Problem
10
Two autoloaders may directly or indirectly include the same dependent library.
Drupal 8
require autoload.php
Badly-Behaved Drush Extension
require autoload.php
"name": "symfony/event-dispatcher",
"version": "v2.7.5",
"name": "symfony/event-dispatcher",
"version": "3.*",
Version Mismatch Breaks
11
Event
isPropagationStopped
stopPropagation
symfony/event-dispatcher v2.7.5 symfony/event-dispatcher v3.x
public function dispatch($event_name, Event $event) {
$event->setDispatcher($this);
Event
isPropagationStopped
stopPropagation
setDispatcher
getDispatcher
getName
setName
DrupalComponentEventDispatcherContainerAwareEventDispatcher.dispatch
Site-Local Drush
12
Solution to Dependency Hell
Well-Behaved Drush Extensions
Site-Local Drush
13
Drush dispatch now happens in four phases:
14
Drush Dispatch
Drush Finder Drush Wrapper Drush Launcher
Drush
Application
15
Drush Finder
Responsible for finding the correct Drush to run
● Checks to see if it can find a Drupal site
● If the Drupal site contains a Drush script, use it
● If no Site-Local Drush is found, use global Drush
Does not look at alias files.
PHP Script
Optional. Located at the Drupal Root if it exists.
User may customize this script to:
● Add site-specific options (e.g. commandfile
locations)
● Select the location of the Drush launcher (if in a
non-standard location)
If there is no Drush Wrapper, then the Drush Finder
will find and execute the Drush Launcher.
16
Drush Wrapper
Shell Script
17
Drush Launcher
Sets up the PHP operating environment.
● Select php.ini file to use
● Select php executable to use
● Passes info about environment to Drush
Always launches the Drush that is located next to it.
Shell Script
18
Drush Application
Contains all the code that is Drush.
● Load configuration and command file
● Parse site alias files
● Might dispatch again, e.g. if site alias is remote
PHP
Application
Manage Drush and Drupal
Place Drush and Drupal in the same composer.json file:
cd /path/to/drupal-8-root
composer require drush/drush:8.*
It is also possible to use site-local Drush with a non-Composer-managed
Drupal site just to attach a specific version of Drush to that site:
cd /path/to/old/drupal-root
composer require drush/drush:6.*
19
CRITICAL
Drush Extensions
20Photo © 2011 by Shawn Clover, CC BY-NA 2.0
PROBLEM:
A Drush extension desires to use Composer
Libraries, but also wants to work with both
Composer-managed sites, and sites that do
not use Composer.
SOLUTION:
Include a composer.json file as usual, and
require libraries there. In your drush extension’
s hook_drush_init, call drush_autoload
(__FILE__).
21
Composer Libraries in Extensions
my.drush.inc:
function my_drush_init() {
drush_autoload(__FILE__);
}
IT’S SIMPLE.
If Drush has located a Drupal site that has an autoloader, then it assumes that
all extensions that need an autoloader are part of the Drupal site’s composer.
json file. Drush only loads Drupal’s autoload.php.
If the Drupal site does not have an autoloader, then Drush will find the
extension’s autoloader, and load it.
AN EXTENSION CAN’T GET THIS RIGHT. ALWAYS USE
drush_autoload.
22
drush_autoload Function
Global Extensions
23
Drush Extensions that use Composer libraries must be included locally as part
of your Drupal project:
cd /path/to/project
composer require drupal/drush_iq
Policy files can continue to live in a global location, e.g. $HOME/.drush.
24
Include Global Extensions in Project
{
"name": "drupal/drupal",
"require": {
"composer/installers": "^1.0.21",
"wikimedia/composer-merge-plugin": "^1.3.0",
"drush/drush": "dev-master"
},
"extra": {
"merge-plugin": {
"include": [
"/Users/ME/.drush-extensions/composer.json"
],
"recurse": false,
"replace": false,
"merge-extra": false
}
},
}
Drupal Project
composer.json:
Global Extensions List
composer.json:
$HOME
└── .drush-extensions
├── composer.json
├── composer.lock
├── drush
│ └── registry_rebuild
│ ├── registry_rebuild.drush.inc
│ └── registry_rebuild.php
└── vendor
└── autoload.php
Drush Configuration Filter
25
Configuration Workflow
26
Code and Content move in only one direction, but Configuration can move in
either direction.
To keep development modules out of exported configuration, define:
__ROOT__/drush/drushrc.php:
$command_specific['config-export']['skip-modules'] = array('devel');
$command_specific['config-import']['skip-modules'] = array(‘devel');
This only works with the Drush config-import and config-export
commands. Use caution with the Configuration Synchronization admin page.
27
Configuration Filter
The Future
28
Drush and Drupal Console
29
The more code you have, the more code you
have to maintain.
However, the maintenance process adds value.
New code should benefit from existing code.
Duplicate functions that do the same thing should
be avoided to reduce maintenance requirements.
&
Drush Bootstrap Refactor
30
Drush now has separate bootstrap
classes for each framework
Boot
validRoot($path);
DrupalBoot6
validRoot($path);
DrupalBoot7
validRoot($path);
DrupalBoot8
validRoot($path);
SOMEDAY?
By factoring Site Aliases and Backend Invoke into separate libraries, the “Drush
Finder” can handle remote dispatches.
31
Refactor into Composer Libraries
Drush Finder Drush Wrapper Drush Launcher Drush Application
cd /path/to/drupal-project
composer require pantheon-systems/behat-drush-endpoint
32
Drush Driver Enhancement
YES!

More Related Content

What's hot

문서화에 날개를 달아주는 Flybook CLI
문서화에 날개를 달아주는 Flybook CLI문서화에 날개를 달아주는 Flybook CLI
문서화에 날개를 달아주는 Flybook CLIRhio Kim
 
DevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal DeploymentDevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal DeploymentGerald Villorente
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Gitdirtytactics
 
How to Use the Command Line to Increase Speed of Development
How to Use the Command Line to Increase Speed of DevelopmentHow to Use the Command Line to Increase Speed of Development
How to Use the Command Line to Increase Speed of DevelopmentAcquia
 
Gdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackGdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackKAI CHU CHUNG
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in developmentAdam Culp
 
Drupal in Libraries
Drupal in LibrariesDrupal in Libraries
Drupal in LibrariesCary Gordon
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaSalvador Molina (Slv_)
 
Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Chris Tankersley
 
Docker workshop
Docker workshopDocker workshop
Docker workshopEvans Ye
 
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Jake Borr
 
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...Puppet
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Phase2
 
How a Content Delivery Network Can Help Speed Up Your Website
How a Content Delivery Network Can Help Speed Up Your WebsiteHow a Content Delivery Network Can Help Speed Up Your Website
How a Content Delivery Network Can Help Speed Up Your WebsiteMediacurrent
 
Into The Box 2018 | Content box + docker
Into The Box 2018 | Content box + dockerInto The Box 2018 | Content box + docker
Into The Box 2018 | Content box + dockerOrtus Solutions, Corp
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stackDana Luther
 
CMake Talk 2008
CMake Talk 2008CMake Talk 2008
CMake Talk 2008cynapses
 

What's hot (20)

문서화에 날개를 달아주는 Flybook CLI
문서화에 날개를 달아주는 Flybook CLI문서화에 날개를 달아주는 Flybook CLI
문서화에 날개를 달아주는 Flybook CLI
 
DevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal DeploymentDevOps: Cooking Drupal Deployment
DevOps: Cooking Drupal Deployment
 
Building a Drupal site with Git
Building a Drupal site with GitBuilding a Drupal site with Git
Building a Drupal site with Git
 
How to Use the Command Line to Increase Speed of Development
How to Use the Command Line to Increase Speed of DevelopmentHow to Use the Command Line to Increase Speed of Development
How to Use the Command Line to Increase Speed of Development
 
Gdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpackGdg cloud taipei ddt meetup #53 buildpack
Gdg cloud taipei ddt meetup #53 buildpack
 
Puppet and Vagrant in development
Puppet and Vagrant in developmentPuppet and Vagrant in development
Puppet and Vagrant in development
 
Drupal in Libraries
Drupal in LibrariesDrupal in Libraries
Drupal in Libraries
 
Exploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molinaExploring composer in drupal 8 with drupal project - salva molina
Exploring composer in drupal 8 with drupal project - salva molina
 
Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017Docker for Developers - php[tek] 2017
Docker for Developers - php[tek] 2017
 
Cmake kitware
Cmake kitwareCmake kitware
Cmake kitware
 
Docker workshop
Docker workshopDocker workshop
Docker workshop
 
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
Drupal Console Deep Dive: How to Develop Faster and Smarter on Drupal 8
 
A Hands-on Introduction to Docker
A Hands-on Introduction to DockerA Hands-on Introduction to Docker
A Hands-on Introduction to Docker
 
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
Scalable Cloud-Native Masterless Puppet, with PuppetDB and Bolt, Craig Watson...
 
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
Best Practices for Development Deployment & Distributions: Capital Camp + Gov...
 
How a Content Delivery Network Can Help Speed Up Your Website
How a Content Delivery Network Can Help Speed Up Your WebsiteHow a Content Delivery Network Can Help Speed Up Your Website
How a Content Delivery Network Can Help Speed Up Your Website
 
Into The Box 2018 | Content box + docker
Into The Box 2018 | Content box + dockerInto The Box 2018 | Content box + docker
Into The Box 2018 | Content box + docker
 
Hands on Docker - Launch your own LEMP or LAMP stack
Hands on Docker -  Launch your own LEMP or LAMP stackHands on Docker -  Launch your own LEMP or LAMP stack
Hands on Docker - Launch your own LEMP or LAMP stack
 
CMake Talk 2008
CMake Talk 2008CMake Talk 2008
CMake Talk 2008
 
Native Hadoop with prebuilt spark
Native Hadoop with prebuilt sparkNative Hadoop with prebuilt spark
Native Hadoop with prebuilt spark
 

Viewers also liked

Migrating NYSenate.gov
Migrating NYSenate.govMigrating NYSenate.gov
Migrating NYSenate.govPantheon
 
How Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on PantheonHow Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on PantheonPantheon
 
WP or Drupal (or both): A Framework for Client CMS Decisions
WP or Drupal (or both): A Framework for Client CMS Decisions WP or Drupal (or both): A Framework for Client CMS Decisions
WP or Drupal (or both): A Framework for Client CMS Decisions Pantheon
 
Testing Your Code as Part of an Industrial Grade Workflow
Testing Your Code as Part of an Industrial Grade WorkflowTesting Your Code as Part of an Industrial Grade Workflow
Testing Your Code as Part of an Industrial Grade WorkflowPantheon
 
Start with Drupal CMS
Start with Drupal CMSStart with Drupal CMS
Start with Drupal CMSEdeth Meng
 
Test Coverage for Your WP REST API Project
Test Coverage for Your WP REST API ProjectTest Coverage for Your WP REST API Project
Test Coverage for Your WP REST API ProjectPantheon
 
WordPress at Scale Webinar
WordPress at Scale WebinarWordPress at Scale Webinar
WordPress at Scale WebinarPantheon
 
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformanceLevel Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformancePantheon
 
Drupal 8 and Pantheon
Drupal 8 and PantheonDrupal 8 and Pantheon
Drupal 8 and PantheonPantheon
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Pantheon
 
Decoupled Architecture and WordPress
Decoupled Architecture and WordPressDecoupled Architecture and WordPress
Decoupled Architecture and WordPressPantheon
 
Drupal Performance
Drupal Performance Drupal Performance
Drupal Performance Pantheon
 
WordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesWordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesPantheon
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsPantheon
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Pantheon
 
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and MoreAutomating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and MorePantheon
 
Development Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesDevelopment Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesPantheon
 

Viewers also liked (17)

Migrating NYSenate.gov
Migrating NYSenate.govMigrating NYSenate.gov
Migrating NYSenate.gov
 
How Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on PantheonHow Drupal 8 Reaches Its Full Potential on Pantheon
How Drupal 8 Reaches Its Full Potential on Pantheon
 
WP or Drupal (or both): A Framework for Client CMS Decisions
WP or Drupal (or both): A Framework for Client CMS Decisions WP or Drupal (or both): A Framework for Client CMS Decisions
WP or Drupal (or both): A Framework for Client CMS Decisions
 
Testing Your Code as Part of an Industrial Grade Workflow
Testing Your Code as Part of an Industrial Grade WorkflowTesting Your Code as Part of an Industrial Grade Workflow
Testing Your Code as Part of an Industrial Grade Workflow
 
Start with Drupal CMS
Start with Drupal CMSStart with Drupal CMS
Start with Drupal CMS
 
Test Coverage for Your WP REST API Project
Test Coverage for Your WP REST API ProjectTest Coverage for Your WP REST API Project
Test Coverage for Your WP REST API Project
 
WordPress at Scale Webinar
WordPress at Scale WebinarWordPress at Scale Webinar
WordPress at Scale Webinar
 
Level Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress PerformanceLevel Up: 5 Expert Tips for Optimizing WordPress Performance
Level Up: 5 Expert Tips for Optimizing WordPress Performance
 
Drupal 8 and Pantheon
Drupal 8 and PantheonDrupal 8 and Pantheon
Drupal 8 and Pantheon
 
Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development Continuous Integration Is for Teams: Moving past buzzword driven development
Continuous Integration Is for Teams: Moving past buzzword driven development
 
Decoupled Architecture and WordPress
Decoupled Architecture and WordPressDecoupled Architecture and WordPress
Decoupled Architecture and WordPress
 
Drupal Performance
Drupal Performance Drupal Performance
Drupal Performance
 
WordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use CasesWordPress REST API: Expert Advice & Practical Use Cases
WordPress REST API: Expert Advice & Practical Use Cases
 
Why Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your ClientsWhy Your Site is Slow: Performance Answers for Your Clients
Why Your Site is Slow: Performance Answers for Your Clients
 
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
Creating a Smooth Development Workflow for High-Quality Modular Open-Source P...
 
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and MoreAutomating & Integrating Pantheon with JIRA, Slack, Jenkins and More
Automating & Integrating Pantheon with JIRA, Slack, Jenkins and More
 
Development Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP LibrariesDevelopment Workflow Tools for Open-Source PHP Libraries
Development Workflow Tools for Open-Source PHP Libraries
 

Similar to Drush in the Composer Era: Using Composer to Manage Drush and Drupal

Composer tools and frameworks for Drupal
Composer tools and frameworks for DrupalComposer tools and frameworks for Drupal
Composer tools and frameworks for DrupalPromet Source
 
A Drush Primer - DrupalCamp Chattanooga 2013
A Drush Primer - DrupalCamp Chattanooga 2013A Drush Primer - DrupalCamp Chattanooga 2013
A Drush Primer - DrupalCamp Chattanooga 2013Chris Hales
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and AegirIztok Smolic
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Developmentjcarrig
 
Drush workshop
Drush workshopDrush workshop
Drush workshopJuampy NR
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAJesus Manuel Olivas
 
Drupal + composer = new love !?
Drupal + composer = new love !?Drupal + composer = new love !?
Drupal + composer = new love !?nuppla
 
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Vlad Savitsky
 
Introduction to Composer for Drupal
Introduction to Composer for DrupalIntroduction to Composer for Drupal
Introduction to Composer for DrupalLuc Bézier
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuis Rodríguez Castromil
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and moreAcquia
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010Florian Latzel
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesGerald Villorente
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowvaluebound
 
Drush installation guide
Drush installation guideDrush installation guide
Drush installation guideThierno Fall
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composernuppla
 
Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with ComposerMatt Glaman
 
Speed up Drupal development with Drush
Speed up Drupal development with DrushSpeed up Drupal development with Drush
Speed up Drupal development with Drushkbasarab
 

Similar to Drush in the Composer Era: Using Composer to Manage Drush and Drupal (20)

Composer tools and frameworks for Drupal
Composer tools and frameworks for DrupalComposer tools and frameworks for Drupal
Composer tools and frameworks for Drupal
 
A Drush Primer - DrupalCamp Chattanooga 2013
A Drush Primer - DrupalCamp Chattanooga 2013A Drush Primer - DrupalCamp Chattanooga 2013
A Drush Primer - DrupalCamp Chattanooga 2013
 
Face your fears: Drush and Aegir
Face your fears: Drush and AegirFace your fears: Drush and Aegir
Face your fears: Drush and Aegir
 
5 Important Tools for Drupal Development
5 Important Tools for Drupal Development5 Important Tools for Drupal Development
5 Important Tools for Drupal Development
 
Drush workshop
Drush workshopDrush workshop
Drush workshop
 
Improving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLAImproving your Drupal 8 development workflow DrupalCampLA
Improving your Drupal 8 development workflow DrupalCampLA
 
Drupal + composer = new love !?
Drupal + composer = new love !?Drupal + composer = new love !?
Drupal + composer = new love !?
 
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
Pavlenko Sergey. Drush: using and creating custom commands. DrupalCamp Kyiv 2011
 
Introduction to Composer for Drupal
Introduction to Composer for DrupalIntroduction to Composer for Drupal
Introduction to Composer for Drupal
 
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDaysLuisRodriguezLocalDevEnvironmentsDrupalOpenDays
LuisRodriguezLocalDevEnvironmentsDrupalOpenDays
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Drush
DrushDrush
Drush
 
Drupal 8 improvements for developer productivity php symfony and more
Drupal 8 improvements for developer productivity  php symfony and moreDrupal 8 improvements for developer productivity  php symfony and more
Drupal 8 improvements for developer productivity php symfony and more
 
drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010drush_multi @ DrupalDevDays 2010
drush_multi @ DrupalDevDays 2010
 
Introduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, TerminologiesIntroduction to Drupal - Installation, Anatomy, Terminologies
Introduction to Drupal - Installation, Anatomy, Terminologies
 
Drupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflowDrupal 8 - Improving your development workflow
Drupal 8 - Improving your development workflow
 
Drush installation guide
Drush installation guideDrush installation guide
Drush installation guide
 
Efficient development workflows with composer
Efficient development workflows with composerEfficient development workflows with composer
Efficient development workflows with composer
 
Managing your Drupal project with Composer
Managing your Drupal project with ComposerManaging your Drupal project with Composer
Managing your Drupal project with Composer
 
Speed up Drupal development with Drush
Speed up Drupal development with DrushSpeed up Drupal development with Drush
Speed up Drupal development with Drush
 

More from Pantheon

Drupal Migrations in 2018
Drupal Migrations in 2018Drupal Migrations in 2018
Drupal Migrations in 2018Pantheon
 
Architecting Million Dollar Projects
Architecting Million Dollar ProjectsArchitecting Million Dollar Projects
Architecting Million Dollar ProjectsPantheon
 
Streamlined Drupal 8: Site Building Strategies for Tight Deadlines
Streamlined Drupal 8: Site Building Strategies for Tight DeadlinesStreamlined Drupal 8: Site Building Strategies for Tight Deadlines
Streamlined Drupal 8: Site Building Strategies for Tight DeadlinesPantheon
 
Getting Started with Drupal
Getting Started with DrupalGetting Started with Drupal
Getting Started with DrupalPantheon
 
Defense in Depth: Lessons Learned Securing 200,000 Sites
Defense in Depth: Lessons Learned Securing 200,000 SitesDefense in Depth: Lessons Learned Securing 200,000 Sites
Defense in Depth: Lessons Learned Securing 200,000 SitesPantheon
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaPantheon
 
Sub-Second Pageloads: Beat the Speed of Light with Pantheon & Fastly
Sub-Second Pageloads: Beat the Speed of Light with Pantheon & FastlySub-Second Pageloads: Beat the Speed of Light with Pantheon & Fastly
Sub-Second Pageloads: Beat the Speed of Light with Pantheon & FastlyPantheon
 
Building a Network of 195 Drupal 8 Sites
Building a Network of 195 Drupal 8 Sites Building a Network of 195 Drupal 8 Sites
Building a Network of 195 Drupal 8 Sites Pantheon
 
Hacking Your Agency Workflow: Treating Your Process Like A Product
Hacking Your Agency Workflow: Treating Your Process Like A ProductHacking Your Agency Workflow: Treating Your Process Like A Product
Hacking Your Agency Workflow: Treating Your Process Like A ProductPantheon
 
Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8Pantheon
 
Preparing for the Internet Zombie Apocalypse
Preparing for the Internet Zombie ApocalypsePreparing for the Internet Zombie Apocalypse
Preparing for the Internet Zombie ApocalypsePantheon
 
Content as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMSContent as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMSPantheon
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowPantheon
 

More from Pantheon (13)

Drupal Migrations in 2018
Drupal Migrations in 2018Drupal Migrations in 2018
Drupal Migrations in 2018
 
Architecting Million Dollar Projects
Architecting Million Dollar ProjectsArchitecting Million Dollar Projects
Architecting Million Dollar Projects
 
Streamlined Drupal 8: Site Building Strategies for Tight Deadlines
Streamlined Drupal 8: Site Building Strategies for Tight DeadlinesStreamlined Drupal 8: Site Building Strategies for Tight Deadlines
Streamlined Drupal 8: Site Building Strategies for Tight Deadlines
 
Getting Started with Drupal
Getting Started with DrupalGetting Started with Drupal
Getting Started with Drupal
 
Defense in Depth: Lessons Learned Securing 200,000 Sites
Defense in Depth: Lessons Learned Securing 200,000 SitesDefense in Depth: Lessons Learned Securing 200,000 Sites
Defense in Depth: Lessons Learned Securing 200,000 Sites
 
Automate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon ViennaAutomate Your Automation | DrupalCon Vienna
Automate Your Automation | DrupalCon Vienna
 
Sub-Second Pageloads: Beat the Speed of Light with Pantheon & Fastly
Sub-Second Pageloads: Beat the Speed of Light with Pantheon & FastlySub-Second Pageloads: Beat the Speed of Light with Pantheon & Fastly
Sub-Second Pageloads: Beat the Speed of Light with Pantheon & Fastly
 
Building a Network of 195 Drupal 8 Sites
Building a Network of 195 Drupal 8 Sites Building a Network of 195 Drupal 8 Sites
Building a Network of 195 Drupal 8 Sites
 
Hacking Your Agency Workflow: Treating Your Process Like A Product
Hacking Your Agency Workflow: Treating Your Process Like A ProductHacking Your Agency Workflow: Treating Your Process Like A Product
Hacking Your Agency Workflow: Treating Your Process Like A Product
 
Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8Best Practice Site Architecture in Drupal 8
Best Practice Site Architecture in Drupal 8
 
Preparing for the Internet Zombie Apocalypse
Preparing for the Internet Zombie ApocalypsePreparing for the Internet Zombie Apocalypse
Preparing for the Internet Zombie Apocalypse
 
Content as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMSContent as a Service: What to Know About Decoupled CMS
Content as a Service: What to Know About Decoupled CMS
 
Drupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed WorkflowDrupal 8 CMI on a Managed Workflow
Drupal 8 CMI on a Managed Workflow
 

Recently uploaded

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

Drush in the Composer Era: Using Composer to Manage Drush and Drupal

  • 1. Drush in the Composer Era 1Photo © 2012 by Charlie Nguyen, CC BY 2.0
  • 2. 2 Overview Using Composer Dependency Hell Site-Local Drush Configuration Filter The FutureDrush Extensions
  • 3. It is now possible to use Composer to add code directly to Drupal: drush dl drupal-8 cd drupal-8 composer require drupal/og:8.* composer update will not update drupal/core; use drush pm-update drupal for this. 3 Standard Composer used in D8
  • 4. web ├── autoload.php ├── composer.json ├── core │ └─ composer.json ├── index.php └── vendor └─ autoload.php 4 wikimedia/composer-merge-plugin { "name": "drupal/drupal", "require": { "composer/installers": "^1.0.21", "wikimedia/composer-merge-plugin": "^1.3.0" }, "extra": { "_readme": [ "By default Drupal loads the autoloader from ./vendor/autoload.php.", "To change the autoloader you can edit ./autoload.php." ], "merge-plugin": { "include": [ "core/composer.json" ], "recurse": false, "replace": false, "merge-extra": false } }, }
  • 5. Uses “split core” to manage Drupal core files: composer create-project drupal- composer/drupal-project:8.x-dev my-site-name --stability dev -- no-interaction 5 Drupal 8: “drupal-project”
  • 6. project ├── composer.json ├── vendor │ └── autoload.php └── web ├── autoload.php ├── core │ └── composer.json └── index.php 6 drupal-project Layout { "name": "drupal-composer/drupal-project", "repositories": [ { "type": "composer", "url": "https://packagist.drupal-composer.org" } ], "require": { "composer/installers": "^1.0.20", "drupal/core": "8.0.*", "drush/drush": "dev-master", "drupal/console": "dev-master" }, "extra": { "installer-paths": { "web/core": ["type:drupal-core"], "web/modules/contrib/{$name}": ["type:drupal-module"], "drush/contrib/{$name}": ["type:drupal-drush"] } } }
  • 7. 7 Drupal 7: Example CI Scripts example-drupal7-circle-composer example-drupal7-travis-composer CI + +
  • 8. Use craychee/rootcanal to post- process your Composer install: "config": { "bin-dir": "bin" }, "scripts": { "post-install-cmd": [ "bin/rootcanal" ], "post-update-cmd": [ "bin/rootcanal" ] } } http://craychee.io/blog/2015/08/01/no-excuses-part3-composer/ 8 Drupal 7: rootcanal
  • 10. The Multiple Autoloaders Problem 10 Two autoloaders may directly or indirectly include the same dependent library. Drupal 8 require autoload.php Badly-Behaved Drush Extension require autoload.php "name": "symfony/event-dispatcher", "version": "v2.7.5", "name": "symfony/event-dispatcher", "version": "3.*",
  • 11. Version Mismatch Breaks 11 Event isPropagationStopped stopPropagation symfony/event-dispatcher v2.7.5 symfony/event-dispatcher v3.x public function dispatch($event_name, Event $event) { $event->setDispatcher($this); Event isPropagationStopped stopPropagation setDispatcher getDispatcher getName setName DrupalComponentEventDispatcherContainerAwareEventDispatcher.dispatch
  • 12. Site-Local Drush 12 Solution to Dependency Hell Well-Behaved Drush Extensions
  • 14. Drush dispatch now happens in four phases: 14 Drush Dispatch Drush Finder Drush Wrapper Drush Launcher Drush Application
  • 15. 15 Drush Finder Responsible for finding the correct Drush to run ● Checks to see if it can find a Drupal site ● If the Drupal site contains a Drush script, use it ● If no Site-Local Drush is found, use global Drush Does not look at alias files. PHP Script
  • 16. Optional. Located at the Drupal Root if it exists. User may customize this script to: ● Add site-specific options (e.g. commandfile locations) ● Select the location of the Drush launcher (if in a non-standard location) If there is no Drush Wrapper, then the Drush Finder will find and execute the Drush Launcher. 16 Drush Wrapper Shell Script
  • 17. 17 Drush Launcher Sets up the PHP operating environment. ● Select php.ini file to use ● Select php executable to use ● Passes info about environment to Drush Always launches the Drush that is located next to it. Shell Script
  • 18. 18 Drush Application Contains all the code that is Drush. ● Load configuration and command file ● Parse site alias files ● Might dispatch again, e.g. if site alias is remote PHP Application
  • 19. Manage Drush and Drupal Place Drush and Drupal in the same composer.json file: cd /path/to/drupal-8-root composer require drush/drush:8.* It is also possible to use site-local Drush with a non-Composer-managed Drupal site just to attach a specific version of Drush to that site: cd /path/to/old/drupal-root composer require drush/drush:6.* 19 CRITICAL
  • 20. Drush Extensions 20Photo © 2011 by Shawn Clover, CC BY-NA 2.0
  • 21. PROBLEM: A Drush extension desires to use Composer Libraries, but also wants to work with both Composer-managed sites, and sites that do not use Composer. SOLUTION: Include a composer.json file as usual, and require libraries there. In your drush extension’ s hook_drush_init, call drush_autoload (__FILE__). 21 Composer Libraries in Extensions my.drush.inc: function my_drush_init() { drush_autoload(__FILE__); }
  • 22. IT’S SIMPLE. If Drush has located a Drupal site that has an autoloader, then it assumes that all extensions that need an autoloader are part of the Drupal site’s composer. json file. Drush only loads Drupal’s autoload.php. If the Drupal site does not have an autoloader, then Drush will find the extension’s autoloader, and load it. AN EXTENSION CAN’T GET THIS RIGHT. ALWAYS USE drush_autoload. 22 drush_autoload Function
  • 23. Global Extensions 23 Drush Extensions that use Composer libraries must be included locally as part of your Drupal project: cd /path/to/project composer require drupal/drush_iq Policy files can continue to live in a global location, e.g. $HOME/.drush.
  • 24. 24 Include Global Extensions in Project { "name": "drupal/drupal", "require": { "composer/installers": "^1.0.21", "wikimedia/composer-merge-plugin": "^1.3.0", "drush/drush": "dev-master" }, "extra": { "merge-plugin": { "include": [ "/Users/ME/.drush-extensions/composer.json" ], "recurse": false, "replace": false, "merge-extra": false } }, } Drupal Project composer.json: Global Extensions List composer.json: $HOME └── .drush-extensions ├── composer.json ├── composer.lock ├── drush │ └── registry_rebuild │ ├── registry_rebuild.drush.inc │ └── registry_rebuild.php └── vendor └── autoload.php
  • 26. Configuration Workflow 26 Code and Content move in only one direction, but Configuration can move in either direction.
  • 27. To keep development modules out of exported configuration, define: __ROOT__/drush/drushrc.php: $command_specific['config-export']['skip-modules'] = array('devel'); $command_specific['config-import']['skip-modules'] = array(‘devel'); This only works with the Drush config-import and config-export commands. Use caution with the Configuration Synchronization admin page. 27 Configuration Filter
  • 29. Drush and Drupal Console 29 The more code you have, the more code you have to maintain. However, the maintenance process adds value. New code should benefit from existing code. Duplicate functions that do the same thing should be avoided to reduce maintenance requirements. &
  • 30. Drush Bootstrap Refactor 30 Drush now has separate bootstrap classes for each framework Boot validRoot($path); DrupalBoot6 validRoot($path); DrupalBoot7 validRoot($path); DrupalBoot8 validRoot($path); SOMEDAY?
  • 31. By factoring Site Aliases and Backend Invoke into separate libraries, the “Drush Finder” can handle remote dispatches. 31 Refactor into Composer Libraries Drush Finder Drush Wrapper Drush Launcher Drush Application
  • 32. cd /path/to/drupal-project composer require pantheon-systems/behat-drush-endpoint 32 Drush Driver Enhancement YES!