Composing Dependencies in Drupal

Drush Make

  • The file format is for Drupal

 

  • Contacts directly drupal.org

 

  • Adding a git repository is very hard

Drupal was isolated on an island ...

So, I put this challenge to the Drupal community: Make your New Year's Resolution to get off the island in 2013. By that I mean get involved in the wider PHP community, both to learn from it and to share with it.

 ...we need enough humility to accept that there are way better ideas floating around out there than exist in Drupal, and we should be open minded enough to learn from them or adopt them wholesale.

Larry Garfield, Getting of the island in 2013, 31 December 2012

 

See http://www.garfieldtech.com/blog/off-the-island-2013

How to leave the island ? 

Stop making, start composing !

Why ?

Let's checkout the Drupal 8

Address Module

Two more packages we didn't asked for.

Those are the dependencies of our dependencies.

 composer update

Once installed, packages can be kept up to date

Drush Make

vs

Composer ? 

Composer resolves dependencies recursively and detect conflicts

Ok fine... but we really need it ? 

YES !!!

Because it generates autoload files !

Composer in Drupal Core !

  • webflo

  • bojanz

  • davidwbaratt

  • derhasi

  • hussainweb

  • kasperg
  • tstoeckler

  • Mile23

  • timmillwood

  • winmillwill

  • yched

  • ...

Meet the team 

Composer in Drupal Core !

  • Support Contrib Modules/Themes with Composer Dependencies

    • Adresss, Drupal Module Upgrader, Markdown Filter, AWS SDK

  • Support Third Party Dependencies

  • Support composer create-project

Composer in Drupal Core !

Problems:

  • core directory is in repository, but Composer places drupal/core in core directory

  • Composer places external dependencies in vendor, but they are duplicated at core/vendor

  • autoload.php needs to updated

  • .gitignore needs to be updated

Composer in Drupal Core !

  • Not a solution: "replace": { "drupal/core" }

    • Does not install dependencies of drupal/core

    • Except if all dependencies are duplicated in composer.json

Composer in Drupal Core !

Composer in Drupal Core !

Composer in Drupal Core !

  • Solution 1:  https://www.drupal.org/project/composer_manager

Composer in Drupal Core !

  • Solution 2:  https://github.com/wikimedia/composer-merge-plugin

    • Example: https://gist.github.com/webflo/c64a5ba25a7f883606ca

Composer in Drupal Core !

  • Solution 3:  

    "require": {

      "composer/installers": "^1.0.21",

      "drupal/core": "~8.0",

      "drupal/address": "8.1.*@dev"

    },

Composer in Drupal Core !

  • Possible Follow-Ups

    • Remove autoload.php

    • Run composer install on Drupal CI and Packaging

    • Remove <root>/vendor alltogether

Packigist

  • All Composer metadata in one place

  • Option: packagist.org

    • requires composer.json

    • requires Semantic Versioning of branches & tags

  • Option: Drupal-specific Packagist implementation

    • can translate existing metadata to Composer format

    • does not work for custom modules and forks

Packigist

Packigist

Semantic Versioning

X.Y.Z.

  • X - incompatible API changes
  • Y - new functionalities
  • Z - bug fixing

Packigist

 

Resources

Thank you !

Sprint on it

on 17 October 2015

at Cluj Hub

Composing Dependencies in Drupal 8

By Popdan Daniel

Composing Dependencies in Drupal 8

This is a presentation about Composer in Drupal 8, mostly based on presentation made by webflo and tstoeckler at DrupalCon Barcelona 2015. The purpose of the presentation is to get familiar with composer and with the issues that are still there and to try to contrib to them at Drupal 8 Code Sprint Cluj-Napoca.

  • 625