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
Tweet

More Decks by Joshua Warren

Other Decks in Programming

Transcript

  1. PRESENTED BY
    JOSHUA
    WARREN
    PRESENTED AT
    PHPWORLD
    2015
    HOW I LEARNED
    TO STOP
    WORRYING AND
    LOVE COMPOSER

    View Slide

  2. View Slide

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

    View Slide

  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

    View Slide

  5. JoshuaWarren.com
    This concept was inspired by
    all of you at php[world] 2014
    #phpworld

    View Slide

  6. JoshuaWarren.com
    “Bringing the entire world of
    PHP one step closer together”
    #phpworld

    View Slide

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

    View Slide

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

    View Slide

  9. View Slide

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

    View Slide

  11. JoshuaWarren.com
    We accomplish so much more
    together than we could on
    our own
    #phpworld

    View Slide

  12. JoshuaWarren.com
    Composer is an amazing tool
    that breaks down barriers to
    re-using open source libraries
    #phpworld

    View Slide

  13. JoshuaWarren.com
    Every framework represented
    at php[world] can be used with
    composer
    #phpworld

    View Slide

  14. JoshuaWarren.com
    Many of the frameworks here
    can be installed with Composer,
    including Magento 2
    #phpworld

    View Slide

  15. JoshuaWarren.com
    Many of the frameworks, though
    - especially those closest to
    end-users - use their own
    module formats
    #phpworld

    View Slide

  16. JoshuaWarren.com
    That’s a problem
    #phpworld

    View Slide

  17. View Slide

  18. View Slide

  19. JoshuaWarren.com
    The community around each
    framework is developing in their
    own silo
    #phpworld

    View Slide

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

    View Slide

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

    View Slide

  22. View Slide

  23. View Slide

  24. View Slide

  25. View Slide

  26. View Slide

  27. View Slide

  28. View Slide

  29. View Slide

  30. JoshuaWarren.com
    if Akismet makes a breaking
    change, that’s 8 developers that
    need to make the same updates
    #phpworld

    View Slide

  31. JoshuaWarren.com
    Repeat this exercise on packagist
    for any popular technology
    #phpworld

    View Slide

  32. JoshuaWarren.com
    We’re wasting so much of our
    effort on duplicating each
    other’s work needlessly
    #phpworld

    View Slide

  33. JoshuaWarren.com
    Thousands of developer-hours
    a year are wasted just building
    framework-specific solutions
    #phpworld

    View Slide

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

    View Slide

  35. JoshuaWarren.com
    STOP IT!
    #phpworld

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  40. View Slide

  41. JoshuaWarren.com
    We can revolutionize the web
    if we focus our efforts on
    solving new problems
    #phpworld

    View Slide

  42. JoshuaWarren.com
    There’s three steps to making
    this change
    #phpworld

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  46. JoshuaWarren.com
    If you find a library that doesn’t
    do quite what you need, improve
    it
    #phpworld

    View Slide

  47. JoshuaWarren.com
    Adapt those existing libraries to
    your framework
    #phpworld

    View Slide

  48. JoshuaWarren.com
    You benefit - you don’t have to
    re-write functionality someone
    else has already written
    #phpworld

    View Slide

  49. JoshuaWarren.com
    The package author benefits
    from your feedback and
    contributions
    #phpworld

    View Slide

  50. JoshuaWarren.com
    The entire community benefits
    from having a focused group of
    high-quality packages
    #phpworld

    View Slide

  51. JoshuaWarren.com
    Adapting these libraries to your
    framework gets time consuming
    #phpworld

    View Slide

  52. JoshuaWarren.com
    If only we had access to some
    sort of tool that could easily
    automate repetitive actions…
    #phpworld

    View Slide

  53. View Slide

  54. JoshuaWarren.com
    Step 2:
    Develop a community standard
    for universal PHP libraries
    #phpworld

    View Slide

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

    View Slide

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

    View Slide

  57. JoshuaWarren.com
    Each package contains
    everything needed for that
    package to run on all PHP
    frameworks
    #phpworld

    View Slide

  58. JoshuaWarren.com
    This puts more work on the
    package author, but less work
    on the frameworks and the
    package users
    #phpworld

    View Slide

  59. JoshuaWarren.com
    The second approach is to build
    a standard, universal package
    format
    #phpworld

    View Slide

  60. JoshuaWarren.com
    Each framework would then
    need an adapter or bridge to
    understand these packages
    #phpworld

    View Slide

  61. JoshuaWarren.com
    Simplifies things for package
    authors
    #phpworld

    View Slide

  62. JoshuaWarren.com
    Early package users have more
    work to do - each framework
    will need an adapter
    #phpworld

    View Slide

  63. JoshuaWarren.com
    Once an adapter for each
    framework is written, this
    approach is easier for everyone
    #phpworld

    View Slide

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

    View Slide

  65. View Slide

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

    View Slide

  67. View Slide

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

    View Slide

  69. JoshuaWarren.com
    “Puli aims to replace specialized
    packages of different
    frameworks with one generic,
    framework independent
    solution.”
    #phpworld

    View Slide

  70. JoshuaWarren.com
    Puli, like Composer, has both a
    command-line tool and a JSON-
    based config file
    #phpworld

    View Slide

  71. JoshuaWarren.com
    Puli adds a layer on top of
    Composer, but doesn’t replace it
    #phpworld

    View Slide

  72. JoshuaWarren.com
    Puli packages are also
    Composer packages
    #phpworld

    View Slide

  73. JoshuaWarren.com
    Puli provides a naming
    convention to access non-PHP
    files from a Puli package
    #phpworld

    View Slide

  74. JoshuaWarren.com
    CSS, images, etc., are stored
    within the Puli package and
    mapped to their framework-
    specific locations
    #phpworld

    View Slide

  75. JoshuaWarren.com
    Puli packages can be both
    consumers and providers of
    resources and PHP classes
    #phpworld

    View Slide

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

    View Slide

  77. JoshuaWarren.com
    Puli has a Symfony bundle/
    bridge, allowing Puli packages
    to work out of the box with
    Symfony
    #phpworld

    View Slide

  78. JoshuaWarren.com
    Similar bridges are needed for
    other frameworks
    #phpworld

    View Slide

  79. JoshuaWarren.com
    Puli is the most developed
    attempt at solving the universal
    package problem in PHP
    #phpworld

    View Slide

  80. JoshuaWarren.com
    Puli isn’t perfect
    #phpworld

    View Slide

  81. JoshuaWarren.com
    Doesn’t handle frameworks
    that manipulate non-PHP config
    files directly on disk
    (I’m looking at you, Magento)
    #phpworld

    View Slide

  82. JoshuaWarren.com
    Hoping to spark a discussion and
    debate around universal
    packages for PHP
    #phpworld

    View Slide

  83. JoshuaWarren.com
    If Puli is the best approach, let’s
    get it integrated with our
    frameworks
    #phpworld

    View Slide

  84. JoshuaWarren.com
    Which takes us to…
    #phpworld

    View Slide

  85. JoshuaWarren.com
    Step 3:
    #phpworld

    View Slide

  86. View Slide

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

    View Slide

  88. JoshuaWarren.com
    Start conversations at your
    local PHP user group about how
    much effort we currently
    duplicate
    #phpworld

    View Slide

  89. JoshuaWarren.com
    Start discussing the two
    different approaches to solving
    the problem
    #phpworld

    View Slide

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

    View Slide

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

    View Slide

  92. JoshuaWarren.com
    When you see someone
    duplicating effort by writing a
    framework-specific extension,
    tell them…
    #phpworld

    View Slide

  93. JoshuaWarren.com
    STOP IT!
    #phpworld

    View Slide

  94. JoshuaWarren.com
    Show them how to re-use an
    existing PHP package via
    Composer
    #phpworld

    View Slide

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

    View Slide

  96. JoshuaWarren.com
    Frameworks like Laravel have
    revolutionized the web by
    reducing the amount of time we
    waste writing boilerplate
    #phpworld

    View Slide

  97. JoshuaWarren.com
    Think about what we can do as a
    community if we stop duplicating
    each other’s work
    #phpworld

    View Slide

  98. JoshuaWarren.com
    Let’s start working together to
    solve new problems
    #phpworld

    View Slide

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

    View Slide

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

    View Slide

  101. JoshuaWarren.com #phpworld

    View Slide