Slide 1

Slide 1 text

www.easybib.com [email protected] Extending Composer Make composer do all the things.

Slide 2

Slide 2 text

www.easybib.com [email protected] Till I’m Till Klampäckel. Good to meet you. @klimpong http://github.com/till http://till.klampaeckel.de/

Slide 3

Slide 3 text

www.easybib.com [email protected] ImagineEasy Solutions LLC We are an information literacy company. What is information literacy?

Slide 4

Slide 4 text

www.easybib.com [email protected] Commercial break Some rights reserved by claire.whitehouse http://www.flickr.com/photos/citysnidget/

Slide 5

Slide 5 text

www.easybib.com [email protected] 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.

Slide 6

Slide 6 text

www.easybib.com [email protected] 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.

Slide 7

Slide 7 text

www.easybib.com [email protected] Anyway There is always more. But that’s not what I’m here for.

Slide 8

Slide 8 text

www.easybib.com [email protected] Composer • Dependency management. • Composer is extendable.

Slide 9

Slide 9 text

www.easybib.com [email protected] 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

Slide 10

Slide 10 text

[email protected] www.easybib.com You want moar?

Slide 11

Slide 11 text

www.easybib.com [email protected] Composer Plugins • From custom installers came plugins.

Slide 12

Slide 12 text

www.easybib.com [email protected] 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.

Slide 13

Slide 13 text

www.easybib.com [email protected] 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” } }

Slide 14

Slide 14 text

www.easybib.com [email protected] 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) { /* ... */ } }

Slide 15

Slide 15 text

www.easybib.com [email protected] Composer Plugin Events • Events live in Composer\Plugin\PluginEvents. • COMMAND • PRE_FILE_DOWNLOAD

Slide 16

Slide 16 text

It’s so simple.

Slide 17

Slide 17 text

www.easybib.com [email protected] 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

Slide 18

Slide 18 text

Go write a plugin. Now.

Slide 19

Slide 19 text

www.easybib.com [email protected] Don’t forget. Publish code. —

Slide 20

Slide 20 text

Wait!

Slide 21

Slide 21 text

www.easybib.com [email protected] 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

Slide 22

Slide 22 text

www.easybib.com [email protected] Questions?