USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not...

53

Transcript of USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not...

Page 1: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies
Page 2: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

USING SUBTREE SPLITS TO SPREAD DRUPAL INTO EVERYTHING

D AV I D B A R R AT T ( D AV I D W B A R R AT T )

Page 3: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

Drupal: Everything except the /core folder.

Drupal core: Everything in the /core folder.

CLARIFICATION

Page 4: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

npmjs.com bower.io

bundler.io

DEPENDENCY MANAGEMENT

Page 5: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DEPENDENCY MANAGEMENT

name = Really Neat Widget description = Provides a really neat widget for your site's sidebar. core = 7.x package = Views dependencies[] = views dependencies[] = panels

in Drupal

Page 6: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

Composer is a tool for dependency management in PHP.

COMPOSERcomposer.org

Page 7: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

CONSUMERS & PROVIDERS

Page 8: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DEPENDENCY MANAGEMENT

name = Really Neat Widget description = Provides a really neat widget for your site's sidebar. core = 7.x package = Views dependencies[] = views dependencies[] = panels

in Drupal

Page 9: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

Projects that consume libraries via Composer

CONSUMERS

Page 10: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

composer.json

{ "require": { "guzzlehttp/guzzle": "~5.0" } }

CONSUMERS

Page 11: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PRO-TIPGenerate (or update) composer.json

$ composer require guzzlehttp/guzzle ~5.0

Page 12: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DOWNLOADING DEPENDENCIES

$ composer install

Page 13: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DOWNLOADING DEPENDENCIESLoading composer repositories with package informationInstalling dependencies (including require-dev) - Installing react/promise (v2.2.0) Loading from cache

- Installing guzzlehttp/streams (3.0.0) Loading from cache

- Installing guzzlehttp/ringphp (1.0.7) Loading from cache

- Installing guzzlehttp/guzzle (5.2.0) Loading from cache

Writing lock fileGenerating autoload files

Page 14: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DOWNLOADING DEPENDENCIES

-rw-r--r-- composer.json-rw-r--r-- composer.lockdrwxr-xr-x vendor

Page 15: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

LOCKING DEPENDENCIES

x

{ "packages": [ { "name": "guzzlehttp/guzzle", "version": "5.2.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", "reference": "475b29ccd411f2fa8a408e64576418728c032cfa" } } ] }

composer.lock

Page 16: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

IGNORING DEPENDENCIES

vendor/

.gitignore

Page 17: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

AUTOLOADING

<?php

require 'vendor/autoload.php';

$client = new GuzzleHttp\Client(); $response = $client->get('http://guzzlephp.org');

Page 18: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

GET OFF THE ISLAND

{ ``"require": { "symfony/yaml": "2.6.*", "twig/twig": "1.18.*", "doctrine/common": "~2.4.2", "doctrine/annotations": "1.2.*", "guzzlehttp/guzzle": "~5.0", "symfony-cmf/routing": "1.3.*", "easyrdf/easyrdf": "0.9.*", "zendframework/zend-feed": "2.4.*", "stack/builder": "1.0.*", "egulias/email-validator": "1.2.*", "masterminds/html5": "~2.1" } }

core/composer.json

Page 19: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #1Issue #1475510

Remove external dependencies from the core repo and let Composer manage the dependencies instead

Page 20: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

$ cd core; composer install;

PROPOSAL #1Issue #1475510

Page 21: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #2Issue #2444615

Move phpunit and mink to require-dev

Page 22: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #2Issue #2444615

{ "require": { "mikey179/vfsStream": "1.*", "stack/builder": "1.0.*", "egulias/email-validator": "1.2.*" }, "require-dev": { "phpunit/phpunit": "4.4.*", "behat/mink": "~1.6", "behat/mink-goutte-driver": "~1.1", "fabpot/goutte": "^2.0.3", "masterminds/html5": "~2.1" } }

Page 23: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

$ cd core; composer install --no-dev;

PROPOSAL #2Issue #2444615

Page 24: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #3

Require Drush as a dev dependency

Page 25: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #3

{ "require-dev": { "drush/drush": "~7.0" } }

Page 26: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

Package (typically a library) that can be consumed by another package or project

PROVIDERS

Page 27: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

composer.jsonPROVIDERS

{ "name": "guzzlehttp/guzzle", }

Page 28: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

composer.jsonPROVIDERS

{ "name": "guzzlehttp/guzzle", "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients" }

Page 29: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

COME TO OUR ISLANDcore/composer.json

{ "name": "drupal/core", "description": "Drupal is an open source content management platform powering millions of websites and applications.", "type": "drupal-core" }

Page 30: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DRUPAL CORE AS A DEPENDENCYcomposer.json

{ "require": { "drupal/core": "~8.0" } }

Page 31: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

A Composer plugin that installs packages of a specific type in a specific directory

COMPOSER INSTALLERScomposer.github.io/installers

Page 32: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DRUPAL CORE AS A DEPENDENCYcomposer.json

{ "require": { "composer/installers": "^1.0.20", "drupal/core": "~8.0" } }

Page 33: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROJECT TYPEcomposer.json

{ "type": "project" }

Page 34: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROJECTS & FRAMEWORKS

Project Framework

Drupal Drupal Core

Symfony Standard Symfony

Laravel Laravel Framework

Page 35: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #4Issue #2385387

Permanently split Drupal and Drupal core into separate repositories

Page 36: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #5Issue #2352091

Create (and maintain) a subtree split of Drupal core

Page 37: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #5Issue #2352091

Page 38: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #5Issue #2352091

Page 39: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #5Issue #2352091

Page 40: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #6

Split each component into a read-only repository

Page 41: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #6core/lib/Drupal/Component/README.txt

Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function.

In other words, only dependencies that can be specified in a composer.json file of the Component are acceptable dependencies. Every Drupal Component presents a valid dependency, because it is assumed to contain a composer.json file (even if it may not exist yet).

16 components are ready to be shared

Page 42: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #6

Page 43: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #6

Page 44: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

CONTRIB

{ "require": { "guzzlehttp/oauth-subscriber": "0.2.*" } }

Page 45: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

COMPOSER MANAGER

Page 46: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

LOAD MODULE WITH COMPOSER

{ "require": { "drupal/really_neat_widget": "8.1.*" } }

composer.json

Page 47: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DRUPAL PACKAGIST packagist.drupal-composer.com

Page 48: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

DRUPAL PACKAGIST

{ "require": { "drupal/really_neat_widget": "7.1.*" }, "repositories": [ { "type": "composer", "url": "https://packagist.drupal-composer.org" } ] }

Page 49: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #6

Provide a Release Webhook & Better APIs

Page 50: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #7

Switch to Semantic Versioning for Drupal contrib extensions (modules, themes, etc)

Issue #1612910

Page 51: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #8

Move packagist to packagist.drupal.org

Page 52: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

PROPOSAL #9

Allow contrib developers to define subfolders (modules or libraries) that should have subtree splits

Page 53: USING SUBTREE SPLITS TO SPREAD - DrupalCon...Drupal Components are independent libraries that do not depend on the rest of Drupal in order to function. In other words, only dependencies

QUESTIONSC O M M E N T S O R I N S U LT S