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

Extending Composer

Extending Composer

A talk I gave at the October meetup of the PHP Usergroup in Berlin.

Till Klampaeckel

October 01, 2013
Tweet

More Decks by Till Klampaeckel

Other Decks in Technology

Transcript

  1. www.easybib.com jobs@imagineeasy.com Till I’m Till Klampäckel. Good to meet you.

    @klimpong http://github.com/till http://till.klampaeckel.de/
  2. www.easybib.com jobs@imagineeasy.com EasyBib.com EasyBib is an citation management platform. 40

    million students use EasyBib every year. Over 1000 institutions subscribe, including 100 large US universities and 900 high schools and districts.
  3. www.easybib.com jobs@imagineeasy.com ResearchReady.com ResearchReady teaches information literacy skills in a

    core curriculum. Universities and districts subscribe to give their students a research skill boost. Launched in January 2013.
  4. www.easybib.com jobs@imagineeasy.com Extending Composer • In the beginning, there were

    custom installers. • Some examples: • custom installers for frameworks • custom installers for software • custom installers for assets and related
  5. www.easybib.com jobs@imagineeasy.com Some very gut advice • Open source project

    management pro tip! • Add a plugin API so you don’t need to maintain what users are doing. • Second pro tip: don’t break the plugin API.
  6. www.easybib.com jobs@imagineeasy.com Composer Plugins { “name”: “till/fancy-plugin”, “license”: “BSD-2-Clause”, “type”:

    “composer-plugin”, “require”: { “composer-plugin-api”: “1.0.0” }, “extra”: { “class”: “till\\Composer\\ExamplePlugin” } }
  7. www.easybib.com jobs@imagineeasy.com Composer Plugins namespace till\Composer; use Composer\Composer, Composer\IO\IOInterface, Composer\Plugin\PluginInterface,

    Composer\Plugin\PluginEvents, Composer\Plugin\CommandEvent; class ExamplePlugin implements PluginInterface { protected $c, $io; public function activate(Composer $c, IOInterface $io) { $this->c = $c; $this->io = $io; } public static function getSubcribedEvents() { return array(PluginEvents::COMMAND => array(array(‘onCommand’, 0))); } public function onCommand(CommandEvent $e) { /* ... */ } }
  8. www.easybib.com jobs@imagineeasy.com Wait, just two? • Currently two events are

    available. • If you need another event, let’s add it. • Example implementations • composer-aws: https://github.com/naderman/composer-aws • composer-newrelic: https://github.com/easybiblabs/composer-newrelic
  9. www.easybib.com jobs@imagineeasy.com Global • `./composer.phar global install|update|require` • I don’t

    want to talk about it too much: http://getcomposer.org/doc/03-cli.md#global • Install plugins globally: ./composer.phar global require till/fancy-plugin:dev-master