Creando sitios con composer en Drupal 8

About

Daniel Noyola

Lead developer

Administrador de dependencias

Porque es util?

  • example.com
  • jQuery@v3.2
  • slider.js
    • jQuery@v2.2
  • modal.js
    • jQuery@1.8

Como funciona un administrador de dependencias?

Ejemplos

Composer

Que es composer?

Composer es una herramienta para administrar dependencias en PHP. Permite declarar librerias de las cuales un proyecto depende y va a administrarlas (instalar/actualizar) por uno.

 

Instalacion

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

mv composer.phar /usr/local/bin/composer

Comandos Basicos

  • composer require vendor/library
  • composer update
  • composer install

Archivos importantes

  • composer.json
  • composer.lock
  • vendors/

composer.json

{
    "name": "vendor/package",
    "require": {
        "monolog/monolog": "1.0.*"
    },
    "require-dev": {
        "phpunit/phpunit": "^6.2"
    }
}

composer.json

{
    "name": "symfony/console",
    "type": "library",
    "description": "Symfony Console Component",
    "keywords": [],
    "homepage": "https://symfony.com",
    "license": "MIT",
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "require": {
        "php": "^7.1.3",
        "symfony/polyfill-mbstring": "~1.0",
        "symfony/debug": "~3.4|~4.0"
    },
    "require-dev": {
        "symfony/config": "~3.4|~4.0",
        "symfony/http-kernel": "~3.4|~4.0",
        "symfony/event-dispatcher": "~3.4|~4.0",
        "symfony/dependency-injection": "~3.4|~4.0",
        "symfony/lock": "~3.4|~4.0",
        "symfony/process": "~3.4|~4.0",
        "psr/log": "~1.0"
    },
    "suggest": {
        "symfony/event-dispatcher": "",
        "symfony/lock": "",
        "symfony/process": "",
        "psr/log": "For using the console logger"
    },
    "conflict": {
        "symfony/dependency-injection": "<3.4",
        "symfony/process": "<3.3"
    },
    "autoload": {
        "psr-4": { "Symfony\\Component\\Console\\": "" },
        "exclude-from-classmap": [
            "/Tests/"
        ]
    },
    "minimum-stability": "dev",
    "extra": {
        "branch-alias": {
            "dev-master": "4.0-dev"
        }
    }
}

Drupal 8

Historia

Librerias en Drupal Core

  • phpunit/phpunit
  • guzzlehttp/guzzle
  • twig/twig
  • symfony/console

Usos en Drupal 8

  • Como arquitecto de sitio de Drupal.
  • Como desarrollador de Drupal.
  • Como responsable de un proyecto de Drupal aportado, .

Drupal 8 + Composer

Drupal ya trae composer.json

2 archivos composer.json!

pero no es recomendado editar ninguna!

Ya alguien encontro la solución!!

composer create-project drupal-composer/drupal-project:8.x-dev my-project --stability dev --no-interaction

Demo

Creando sitios con composer en drupal 8

By Daniel Noyola

Creando sitios con composer en drupal 8

  • 135
Loading comments...

More from Daniel Noyola