A talk by Rodrigo Aguilera / @marinero
Focused on processes, workflows and shared tools
Took less time to write (or copypaste) a solution yourself than to find a component you can reuse.
Sharing must be easy or it won't happen.
Free software as a feature.
api = 2
core = 7.*
projects[views] = 3.1
projects[ctools] = 1.0-rc1
projects[media] = 2.x-dev
projects[nodequeue][subdir] = contrib
projects[nodequeue][version] = 2.0-alpha1
projects[nodequeue][patch][] = "http://drupal.org/files/issues/1023606-qid-to-name-6.patch"
projects[nodequeue][patch][] = "http://drupal.org/files/issues/nodequeue_d7_autocomplete-872444-6.patch"
libraries[jquery.cycle][download][type] = get
libraries[jquery.cycle][download][url] = http://malsup.com/jquery/cycle/release/jquery.cycle.zip?v2.99
libraries[jquery.cycle][destination] = libraries
Just by looking at the composer.json in drupal core
Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.
# Quick-n-easy:
$ curl -sS https://getcomposer.org/installer | php
# Global
$ curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
Base manifest file for your project
{
"name": "rodrigoaguilera/mydrupalsite",
"description": "This site is awesome.",
"require": {
"drupal/honeypot": "1.*"
},
"require-dev": {
"drupal/devel": "1.*"
},
"config": {},
"extra": {}
}
composer install
Reads composer.lock and downloads all your dependencies in the /vendor directory.
composer update [<vendor>/<package>]
Writes a new composer.lock based on what is on composer.json and downloads only what is missing.
You can update only one package to do more atomic updates.
composer require <vendor>/<package>:"<version-constrain>"
The concept of repositories.
Main repository for packages.
There is also https://packages.drupal.org/8 as a mirror of the modules and themes on drupal.org
vendor/bin/drush
composer exec drush
$COMPOSER_HOME
to be set)
"config": {
"platform": {
"php": "5.6.2",
"ext-mongodb": "1.1"
}
}
composer install --prefer-dist --no-dev --optimize-autoloader
require-dev
section is ignoredThe composer.json for a project (the root package) has more capabalities like:
{
"require": {
"cweagans/composer-patches": "~1.0",
"drupal/drupal": "8.5.*@dev"
},
"config": {
"preferred-install": "source"
},
"extra": {
"patches": {
"drupal/drupal": {
"Add startup configuration for PHP server": "https://www.drupal.org/files/issues/add_a_startup-1543858-30.patch"
}
}
}
}
install
or update
composer install
composer install
composer install
composer update
Composer template for drupal projects comes to the rescue.
https://github.com/drupal-composer/drupal-project
drupal-[module|theme|profile]
) will be placed in web/[module|theme|profile]/contrib/
settings.php
.vendor/bin/drush
.vendor/bin/drupal
.composer require npm-asset/bootstrap-sass:"^3"
oomphinc/composer-installers-extender
to define custom pathsFor example:
"minimum-stability": "dev"
You can be more semantic and declare it for each package like
composer require "drupal/webform":"^5@beta",
"config": {
"sort-packages": true,
"discard-changes": true,
"process-timeout": 600,
"platform": {
"php": "7.1.0"
}
}
Committing dependencies in the repo
Multumesc.
- https://getcomposer.org/