The best Drupal news and links delivered to your inbox every week

Composer: There's A Module (or Library) For That - Rob Loach and Larry Garfield - DrupalCon Portland 2013

Check out the DrupalCon Portland notes hub page for notes from other sessions at DrupalCon Portland.

Session: Composer: There's A Module (or Library) For That

Day - Time Slot: Wednesday, May 22 - 05:00pm–06:00pm

Presenters:

Rob Loach
Twitter: RobLoach
Web site: robloach.net
Drupal.org: RobLoach

Larry Garfield
Twitter: Crell
Web site: garfieldtech.com
Drupal.org: Crell

Session page

Slides

Video

Dependency Management in PHP

  • PHP sucks at sharing
  • Sharing is how open source works
  • Sucking at sharing is how Open Source projects die
  • Drupal.org is great but only for Drupal
  • Drush make is great but only works for Drupal
  • Other communities have solved this problem
  • Code on d.o is not reusable. Only works in Drupal
  • The world is bigger than Drupal

Third party Code in Drupal

  • Manually download and hope it doesn’t break

Pear

  • You could sort of share code in PHP4
  • Requires root. Problem on shared hosting
  • Hard to add packages to the repo
  • Easy to get it wrong

Symfony 2.0 & PHPBB

  • Symfony 2 uses 3rd party libs (Doctrine, Monolog)
  • Dependency Hell
  • Enter Composer which handles dependency management

Composer

  • No more copy paste of libs
  • resolved dep
  • each project define it own requirements
  • Preforms build tasks
  • Handles auto loading code
  • Like module .info files
  • Packagist.org Over 10,000 packages available

Libraries available via Composer

  • Symfony which is a collection of components available via Composer
  • ZEND framework is now available through Packagist
  • PHPUnit: Unit testing for PHP
  • Guzzle: in Drupal 8
  • Solarium: Solr library for PHP
  • Elastica: Search engine lib
  • Monolog: Logging for web services
  • Assetic: JS, CSS and image asset management
  • Drupal will be… but not yet

Sharing on Packagist

  • One JSON manifest file
  • Composer install file will load dependencies and downloads the projects with version info
  • Autoload in in index.php registers the library in your app
  • This allows you to only include YOUR code in your repo
  • Composer update will update all dependencies and vendor code
  • Schema Docs
  • You can host your own repositories with Satis

How to Use Composer with Drupal

  • Use Drush! There is a composer wrapper that lets you use it with drush
  • There’s a module for that! Composer autoload module
  • Composer manager module: Builds with json files and you can use Drush to do this.
  • Composer Installers It will install their package to the correct location based on the specified package type.
  • Drupal Packagist allows you to use Composer to download Drupal projects. Very early project

What are you waiting for? Subscribe already.

Published by Bob Kepford

Powered by Drupal