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

How I Learned to Stop Worrying and Love Composer - php[world] 2015

How I Learned to Stop Worrying and Love Composer - php[world] 2015

WordPress extensions, Drupal modules, Magento extensions — developers are building amazing features for each platform. But what if, instead of building platform-specific features, we built reusable packages? All of our platforms can be used with Composer — Magento 2 is even fully installable via Composer & developers can pull in specific Magento components to non-Magento projects, as well. However, we still write extensions for our platform & don't write reusable PHP packages. Let's look at how we all benefit by changing this mindset and how to start writing reusable cross-platform packages.

Joshua Warren

November 19, 2015

More Decks by Joshua Warren

Other Decks in Programming



  2. None
  3. JoshuaWarren.com Slides will be available at joind.in/14788 #phpworld

  4. JoshuaWarren.com My Experience PHP Developer Since 1999 Founded Creatuity in

    2008 Focused on the Magento platform Previous experience w/WordPress, Joomla, Drupal, Yii #phpworld
  5. JoshuaWarren.com This concept was inspired by all of you at

    php[world] 2014 #phpworld
  6. JoshuaWarren.com “Bringing the entire world of PHP one step closer

    together” #phpworld
  7. JoshuaWarren.com Cross-pollinating ideas between PHP frameworks and applications #phpworld

  8. JoshuaWarren.com One common idea I heard repeatedly at php[world] 2014

  9. None
  10. JoshuaWarren.com Open source allows us to pool our efforts #phpworld

  11. JoshuaWarren.com We accomplish so much more together than we could

    on our own #phpworld
  12. JoshuaWarren.com Composer is an amazing tool that breaks down barriers

    to re-using open source libraries #phpworld
  13. JoshuaWarren.com Every framework represented at php[world] can be used with

    composer #phpworld
  14. JoshuaWarren.com Many of the frameworks here can be installed with

    Composer, including Magento 2 #phpworld
  15. JoshuaWarren.com Many of the frameworks, though - especially those closest

    to end-users - use their own module formats #phpworld
  16. JoshuaWarren.com That’s a problem #phpworld

  17. None
  18. None
  19. JoshuaWarren.com The community around each framework is developing in their

    own silo #phpworld
  20. JoshuaWarren.com We’re duplicating (wasting!) massive amounts of effort #phpworld

  21. JoshuaWarren.com We all hate spam, right? #phpworld

  22. None
  23. None
  24. None
  25. None
  26. None
  27. None
  28. None
  29. None
  30. JoshuaWarren.com if Akismet makes a breaking change, that’s 8 developers

    that need to make the same updates #phpworld
  31. JoshuaWarren.com Repeat this exercise on packagist for any popular technology

  32. JoshuaWarren.com We’re wasting so much of our effort on duplicating

    each other’s work needlessly #phpworld
  33. JoshuaWarren.com Thousands of developer-hours a year are wasted just building

    framework-specific solutions #phpworld
  34. JoshuaWarren.com In the words of Bob Newhart on Mad TV…

  35. JoshuaWarren.com STOP IT! #phpworld

  36. JoshuaWarren.com No excuses, just stop it. #phpworld

  37. JoshuaWarren.com Let’s write composer packages that can work on all

    frameworks #phpworld
  38. JoshuaWarren.com contribute to existing PHP packages instead of creating framework-specific

    packages #phpworld
  39. JoshuaWarren.com We’re smart people. We’re developers. You could even say…

  40. None
  41. JoshuaWarren.com We can revolutionize the web if we focus our

    efforts on solving new problems #phpworld
  42. JoshuaWarren.com There’s three steps to making this change #phpworld

  43. JoshuaWarren.com Step 1: change your way of thinking #phpworld

  44. JoshuaWarren.com Stop looking for framework- specific extensions #phpworld

  45. JoshuaWarren.com Start your search on Packagist #phpworld

  46. JoshuaWarren.com If you find a library that doesn’t do quite

    what you need, improve it #phpworld
  47. JoshuaWarren.com Adapt those existing libraries to your framework #phpworld

  48. JoshuaWarren.com You benefit - you don’t have to re-write functionality

    someone else has already written #phpworld
  49. JoshuaWarren.com The package author benefits from your feedback and contributions

  50. JoshuaWarren.com The entire community benefits from having a focused group

    of high-quality packages #phpworld
  51. JoshuaWarren.com Adapting these libraries to your framework gets time consuming

  52. JoshuaWarren.com If only we had access to some sort of

    tool that could easily automate repetitive actions… #phpworld
  53. None
  54. JoshuaWarren.com Step 2: Develop a community standard for universal PHP

    libraries #phpworld
  55. JoshuaWarren.com There are two ways to approach universal PHP packages

  56. JoshuaWarren.com First - packages that have multi- framework support built

    in #phpworld
  57. JoshuaWarren.com Each package contains everything needed for that package to

    run on all PHP frameworks #phpworld
  58. JoshuaWarren.com This puts more work on the package author, but

    less work on the frameworks and the package users #phpworld
  59. JoshuaWarren.com The second approach is to build a standard, universal

    package format #phpworld
  60. JoshuaWarren.com Each framework would then need an adapter or bridge

    to understand these packages #phpworld
  61. JoshuaWarren.com Simplifies things for package authors #phpworld

  62. JoshuaWarren.com Early package users have more work to do -

    each framework will need an adapter #phpworld
  63. JoshuaWarren.com Once an adapter for each framework is written, this

    approach is easier for everyone #phpworld
  64. JoshuaWarren.com A Symfony developer has found the solution for this

    approach… #phpworld
  65. None
  66. JoshuaWarren.com Puli: no longer just a unique looking dog breed

  67. None
  68. JoshuaWarren.com puli.io - Universal Packages for PHP #phpworld

  69. JoshuaWarren.com “Puli aims to replace specialized packages of different frameworks

    with one generic, framework independent solution.” #phpworld
  70. JoshuaWarren.com Puli, like Composer, has both a command-line tool and

    a JSON- based config file #phpworld
  71. JoshuaWarren.com Puli adds a layer on top of Composer, but

    doesn’t replace it #phpworld
  72. JoshuaWarren.com Puli packages are also Composer packages #phpworld

  73. JoshuaWarren.com Puli provides a naming convention to access non-PHP files

    from a Puli package #phpworld
  74. JoshuaWarren.com CSS, images, etc., are stored within the Puli package

    and mapped to their framework- specific locations #phpworld
  75. JoshuaWarren.com Puli packages can be both consumers and providers of

    resources and PHP classes #phpworld
  76. JoshuaWarren.com Learn more about Puli at puli.io or on Speakerdeck.

  77. JoshuaWarren.com Puli has a Symfony bundle/ bridge, allowing Puli packages

    to work out of the box with Symfony #phpworld
  78. JoshuaWarren.com Similar bridges are needed for other frameworks #phpworld

  79. JoshuaWarren.com Puli is the most developed attempt at solving the

    universal package problem in PHP #phpworld
  80. JoshuaWarren.com Puli isn’t perfect #phpworld

  81. JoshuaWarren.com Doesn’t handle frameworks that manipulate non-PHP config files directly

    on disk (I’m looking at you, Magento) #phpworld
  82. JoshuaWarren.com Hoping to spark a discussion and debate around universal

    packages for PHP #phpworld
  83. JoshuaWarren.com If Puli is the best approach, let’s get it

    integrated with our frameworks #phpworld
  84. JoshuaWarren.com Which takes us to… #phpworld

  85. JoshuaWarren.com Step 3: #phpworld

  86. None
  87. JoshuaWarren.com Change the community’s way of thinking #phpworld

  88. JoshuaWarren.com Start conversations at your local PHP user group about

    how much effort we currently duplicate #phpworld
  89. JoshuaWarren.com Start discussing the two different approaches to solving the

    problem #phpworld
  90. JoshuaWarren.com Introduce people to Puli & provide feedback on Github

    to the Puli project #phpworld
  91. JoshuaWarren.com Implement a Puli integration for your favorite framework #phpworld

  92. JoshuaWarren.com When you see someone duplicating effort by writing a

    framework-specific extension, tell them… #phpworld
  93. JoshuaWarren.com STOP IT! #phpworld

  94. JoshuaWarren.com Show them how to re-use an existing PHP package

    via Composer #phpworld
  95. JoshuaWarren.com Start your new projects as Composer packages, not application-specific

    extensions #phpworld
  96. JoshuaWarren.com Frameworks like Laravel have revolutionized the web by reducing

    the amount of time we waste writing boilerplate #phpworld
  97. JoshuaWarren.com Think about what we can do as a community

    if we stop duplicating each other’s work #phpworld
  98. JoshuaWarren.com Let’s start working together to solve new problems #phpworld

  99. JoshuaWarren.com We can change the web - and the world

  100. Keep in Touch! @JoshuaSWarren JoshuaWarren.com Mage2DevBook.com joind.in/14788

  101. JoshuaWarren.com #phpworld