Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Modern Drupal Development with Composer

Modern Drupal Development with Composer

PHPSW lightning talk

Oliver Davies

November 09, 2016
Tweet

More Decks by Oliver Davies

Other Decks in Programming

Transcript

  1. Modern Drupal
    Development with
    Composer
    PHPSW Lightning Talks ‐ November 2016

    View Slide

  2. Oliver Davies
    Senior Drupal/PHP Developer
    Appnova on Technologies
    @opdavies

    View Slide

  3. The Old Ways
    Download an archive from Drupal.org
    Use Drush commands (drush dl)
    Use Drush Make

    View Slide

  4. Composer
    Drupal Packagist (deprecated)
    Composer endpoints on Drupal.org (beta)
    Manage core and contrib as dependencies
    Both Drupal 7 and 8

    View Slide

  5. Why?
    "Ge ng off the island"
    Be er versioning support
    Automa c dependency management

    View Slide

  6. Add a new repository
    $ composer config \
    repositories.drupal composer \
    https://packages.drupal.org/8

    View Slide

  7. composer.json
    {
    "repositories": {
    "drupal": {
    "type": "composer",
    "url": "https://packages.drupal.org/8"
    }
    }
    }

    View Slide

  8. Custom directories
    "extra": {
    "installer-paths": {
    "modules/contrib/{$name}": ["type:drupal-module"],
    "profiles/contrib/{$name}": ["type:drupal-profile"],
    "themes/contrib/{$name}": ["type:drupal-theme"]
    }
    }

    View Slide

  9. Adding Modules
    $ composer require drupal/pathauto:^1.0
    ...
    - Installing drupal/token (1.0.0-beta2)
    Downloading: 100%
    - Installing drupal/ctools (3.0.0-alpha27)
    Downloading: 100%
    - Installing drupal/pathauto (1.0.0-beta1)
    Downloading: 100%

    View Slide

  10. Adding Modules with Dependencies
    $ composer require drupal/address:^1.0
    ...
    - Installing commerceguys/addressing (v1.0.0-beta1)
    Downloading: 100%
    ...
    - Installing drupal/address (1.0.0-rc3)
    Downloading: 100%

    View Slide

  11. Composer project for Drupal projects
    Downloads core into web/
    Uses Composer’s autoload.php
    Custom directories for modules, themes, profiles
    Manages directories and file permissions
    Includes Drush and Drupal Console

    View Slide

  12. Composer project for Drupal projects
    $ composer create-project \
    drupal-composer/drupal-project:8.x-dev \
    some-dir --stability dev \
    --no-interaction

    View Slide

  13. Demo
    0:00 / 1:26

    View Slide

  14. Resources
    Using Composer to manage Drupal site
    dependencies ‐
    h ps:/
    /www.drupal.org/node/2718229
    Composer template for Drupal projects ‐
    h ps:/
    /github.com/drupal‐composer/drupal‐
    project

    View Slide

  15. Questions?

    View Slide