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

Using & Extending Composer

Using & Extending Composer

My talk from Symfony Live 2013 in Berlin.

1e078b34687f7a685b078ac7b0b02a55?s=128

Till Klampaeckel

November 07, 2013
Tweet

Transcript

  1. www.easybib.com jobs@imagineeasy.com Using & Extending Composer Your daily life with

    Composer
  2. www.easybib.com jobs@imagineeasy.com Till I’m Till Klampäckel

  3. www.easybib.com jobs@imagineeasy.com Till Good to meet you.

  4. www.easybib.com jobs@imagineeasy.com Find me online @klimpong
 http://github.com/till
 http://till.klampaeckel.de/


  5. www.easybib.com jobs@imagineeasy.com Till 15 years of experience

  6. www.easybib.com jobs@imagineeasy.com ImagineEasy Solutions LLC An information literacy company.

  7. www.easybib.com jobs@imagineeasy.com Information Literacy •avoid plagiarism •evaluate sources

  8. 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.
  9. 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.
  10. www.easybib.com jobs@imagineeasy.com Stack •PHP (5.3 & 5.4, on the way

    to 5.5) •Nginx + Linux •AWS (OpsWorks, RDS, ElasticCache) •Solr, ElasticSearch •CouchDB / BigCouch •Travis-CI, PHPUnit, Behat •Vagrant, Chef, Virtualbox, Packer
  11. www.easybib.com jobs@imagineeasy.com Commercial break Some rights reserved by claire.whitehouse http://www.flickr.com/photos/citysnidget/

    SOUNDS GOOD?
 WE’RE HIRING! till+symfonylive@imagineeasy.com
  12. www.easybib.com jobs@imagineeasy.com Composer We embrace it.

  13. www.easybib.com jobs@imagineeasy.com Composer Dependency management

  14. www.easybib.com jobs@imagineeasy.com Composer Dependency resolution

  15. www.easybib.com jobs@imagineeasy.com Composer Semantic Versioning


  16. www.easybib.com jobs@imagineeasy.com Composer Major.Minor.Bugfix
 1.0.1

  17. www.easybib.com jobs@imagineeasy.com Composer http://semver.org/

  18. www.easybib.com jobs@imagineeasy.com Composer Your first package

  19. www.easybib.com jobs@imagineeasy.com Composoring your code {
 “name”: “till/secret-sauce”,
 “license”: “MIT”


    }
  20. www.easybib.com jobs@imagineeasy.com Next step Publish code. —

  21. www.easybib.com jobs@imagineeasy.com Packagist •register on packagist.org •submit your package •setup

    the service-hook
 (Github)
  22. www.easybib.com jobs@imagineeasy.com Ship it!

  23. www.easybib.com jobs@imagineeasy.com Shipping it • `git tag -a 1.0.0 -m

    “this is my rock-solid 1.0.0”`
 `git push --tags` • `svn cp trunk tags/1.0.0`
  24. www.easybib.com jobs@imagineeasy.com Consuming {
 “name”: “fabpot/awesome”,
 “require”: {
 “till/secret-sauce”: “~1.0”


    }
 }
  25. www.easybib.com jobs@imagineeasy.com Consuming {
 “name”: “fabpot/awesome”,
 “repositories”: [
 {
 “type”:”package”,


    “package”: {
 “name”: “sensio/legacy-code”,
 “version”: “3.2.4”,
 “dist”: {
 “url”: “http://dev.local/secret.zip”,
 “type”: “zip”
 }
 }
 }
 ],
 “require”: {
 “sensio/legacy-code”: “3.2.4”,
 “till/secret-sauce”: “~1.0”
 }
 }
  26. ACHTUNG, ACHTUNG.

  27. www.easybib.com jobs@imagineeasy.com Repositories • Repositories are not inherited. • Put

    open source code on packagist, or get satis.
  28. www.easybib.com jobs@imagineeasy.com Consuming • There are a lot, lot more

    options. • Check http://getcomposer.org/
  29. www.easybib.com jobs@imagineeasy.com Installing cd awesome-application
 curl -sS http://getcomposer.org/installer |php
 ./composer.phar

    install
  30. www.easybib.com jobs@imagineeasy.com What else? • Update your dependencies. • Search

    for dependencies. • Development dependencies. • Classmap and PSR-0 autoloaders. • “help”
  31. Breath.

  32. www.easybib.com jobs@imagineeasy.com One more thing Do you know composer’s global

    command?
  33. www.easybib.com jobs@imagineeasy.com Go PEAR! Go global! •$COMPOSER_HOME/composer.json •./composer.phar global install

  34. www.easybib.com jobs@imagineeasy.com Satis Your own private packagist.org.

  35. Because what could go wrong?

  36. www.easybib.com jobs@imagineeasy.com Things that will go wrong • Github is

    down. • Packagist is down. • Internet is slow. • Internet doesn’t work. • Tags get deleted. (cc fabpot :)
  37. Own your availability!

  38. www.easybib.com jobs@imagineeasy.com Captain Obvious Your proprietary code is private.

  39. www.easybib.com jobs@imagineeasy.com Setup ./composer.phar \
 create-project \
 composer/satis \
 --stability=dev

    \
 --prefer-dist
  40. www.easybib.com jobs@imagineeasy.com satis.json {
 "name": "Till's satis",
 "homepage": "http://satis.local",
 "require-all":

    true,
 "repositories": [
 {"packagist": false},
 {
 "type":"vcs",
 "url":"http://github.com/fabpot/symfony"
 }
 ]
 }
  41. www.easybib.com jobs@imagineeasy.com Build ./bin/satis build ./satis.json public php -S 0.0.0.0:80

    -t public
  42. www.easybib.com jobs@imagineeasy.com Build

  43. www.easybib.com jobs@imagineeasy.com Go back {
 “name”: “fabpot/awesome”,
 “repositories”: [
 {


    “type”:”composer”,
 “url”: “http://satis.local”
 }
 ],
 “require”: {
 “sensio/legacy-code”: “3.2.4”,
 “till/secret-sauce”: “~1.0”
 }
 }
  44. www.easybib.com jobs@imagineeasy.com Next steps • fork code — e.g. to

    a local backup server • generate your own downloads • configure Amazon S3 as a backend
  45. www.easybib.com jobs@imagineeasy.com Next steps http://www.flickr.com/photos/mightymightymatze/

  46. Want even more?

  47. www.easybib.com jobs@imagineeasy.com Extending Composer Or, bending Composer to your will.

  48. www.easybib.com jobs@imagineeasy.com Plugins

  49. www.easybib.com jobs@imagineeasy.com Composer installer

  50. www.easybib.com jobs@imagineeasy.com Composer installer Install jQuery, bootstrap, etc.! https://github.com/RobLoach/component-installer

  51. www.easybib.com jobs@imagineeasy.com Composer installer • aura • ezPublish • flow/typo3

    • fuel • magento • wordpress • yii
  52. www.easybib.com jobs@imagineeasy.com Event-Plugins

  53. www.easybib.com jobs@imagineeasy.com Plugin Events COMMAND
 https://github.com/easybiblabs/composer-newrelic


  54. www.easybib.com jobs@imagineeasy.com Plugin Events PRE_FILE_DOWNLOAD
 https://github.com/naderman/composer-aws


  55. We’re almost done!

  56. Lessons learned.

  57. www.easybib.com jobs@imagineeasy.com Deploying with Composer is hard

  58. www.easybib.com jobs@imagineeasy.com Github is down more
 often than you think

  59. www.easybib.com jobs@imagineeasy.com Github is not down as often as you

    think :)
  60. www.easybib.com jobs@imagineeasy.com API limits suck

  61. www.easybib.com jobs@imagineeasy.com Composer wants your RAM

  62. www.easybib.com jobs@imagineeasy.com ~/.composer/config.json

  63. www.easybib.com jobs@imagineeasy.com Always “composer validate”

  64. www.easybib.com jobs@imagineeasy.com Always check in the “composer.phar”

  65. www.easybib.com jobs@imagineeasy.com Versioning is hard

  66. www.easybib.com jobs@imagineeasy.com Dependency resolution

  67. www.easybib.com jobs@imagineeasy.com “composer update” broke my app

  68. www.easybib.com jobs@imagineeasy.com #1 contender for merge conflicts: The composer.lock

  69. www.easybib.com jobs@imagineeasy.com Thanks! Questions?