On Github rodrigoaguilera / talk_composer
A talk by Rodrigo Aguilera / @marinero
Because I knew there was something better.I'm from Madrid, now I live in Barcelona. I'm 29. I work as a drupal developer at Ymbra, Citilab. I have a curiosity to improve process. Previously on...
Takes less time to write a solution yourself than to find a component you can reuse.
Is not such a bad idea but it wasn't getting PHP to be any good.Sharing must be easy or it won't happen.
Free software as a feature.
Free software as a practical tool comes into play because you see all this different projects sharing code.
It wasn't part of drush and then it got merged into it. answers the problem about not having drupal and modules in repo.
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] = librariesBrings automation Allows patches, fixing version, external libraries, choice of folder, not all the code in the repository, can get from cvs. This in INI format, it also supports YAML.
PHP is going to parties and drupal is not invited.
Just by looking at the composer.json in drupal core
Ugly logo.
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.
When we say libraries it can be other pieces of php code like themes or modules.
# Quick-n-easy: $ curl -sS https://getcomposer.org/installer | php # Global $ curl -sS https://getcomposer.org/installer | php -- --install-dir=binThis installs a binary.
Main repository for packages. There is also https://packagist.drupal-composer.org/ as a mirror of the modules and themes on drupal.org
It had an exponential grow. Declares what is stable It manages outdated packages.
composer require <vendor>/<package>It will write your json for you.
Base manifest file for your project
{ "name": "rodrigoaguilera/mydrupalsite", "description": "This site is awesome.", "require": { "drupal/honeypot": "8.1.*" }, "require-dev": { "drupal/devel": "8.1.*" } }Is another shopping list but for higher level stuff. Commerce as an example that uses it extensibly.
Dependencies solved. Is the key for everyone to have the same versions. Always commit your lock file.
Everything downloaded with an exact version number. Lock is a bigger file.Reads composer.lock and downloads all your dependencies in the /vendor directory.
Everything gets a cache. Needed to develop drupal 8.1.xWrites a new composer.lock based on what is on composer.json and downloads what is needed You can update only one package to do more atomic updates.
For last release crazies.
vendor/bin/drush
composer exec drushExamples: drush, phpunit, phpcs, behat... Is a problem not easy to solve for newbies. Drush solves it with drush launcher.
The power of comes from having per project dependencies. but you can also install composer packages shared by everything and everyone. Use "composer global" before commands. (neeeds $COMPOSER_HOME)
Computer vs. only my repo. Same for config.
"config": { "platform": { "php": "5.6.2", "ext-mongodb": "1.1" } }Follow restrictions.
All packagist supports this. A new feature of drupal 8. Contrib doesn't support it.
composer install --prefer-dist --no-dev --optimize-autoloader
The composer.json for a project has more capabalities like:
{ "require": { "cweagans/composer-patches": "~1.0", "drupal/drupal": "8.0.*@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" } } } }
Composer template for drupal projects comes to the rescue. https://github.com/drupal-composer/drupal-project
Is conceived as a replacement for drush make. People from pantheon, acquia are contributing.
Thank you. - https://getcomposer.org/