Unglue All The Things! Forum PHP Paris 2015

Unglue All The Things! Forum PHP Paris 2015

Bundles. Packages. Modules. Plugins. So much code is locked up in framework-specific packages. Integration packages are not bad, but losing the ability to reuse code that has nothing to do with a specific framework's implementation is! Don't let reusable code get locked into framework-specific glue packages! Come see practical strategies for writing framework agnostic code and walk away having a better idea how you, too, can unglue all the things!

23d971deeb3975a7d28246192fbbe7b7?s=128

Beau Simensen

November 23, 2015
Tweet

Transcript

  1. 9.
  2. 14.
  3. 15.
  4. 16.
  5. 21.
  6. 23.
  7. 32.
  8. 39.

    Symfony handled this by convention (this is one reason why

    so many projects ship everything as a bundle)
  9. 40.

    Won't work if the mappings live in a project other

    than a bundle* * Nasty __DIR__ hacks don't count.
  10. 47.

    "autoload": { "psr-0": { "Monii\\Deal\\": "src" } } Monii\Deal\DealRepository =>

    src/Monii/Deal/DealRepository.php Monii\Deal\DealRepository => vendor/monii/deal/src/Monii/Deal/DealRepository.php
  11. 48.

    What if we used PSR-0 mappings and rules to locate

    other types of files than just classes?
  12. 50.

    "autoload": { "psr-0": { "Monii\\Deal\\": "src" } } Monii\Deal\DealRepository =>

    src/Monii/Deal/DealRepository.php classpath:Monii/Deal/resources/mapping.yml => src/Monii/Deal/resources/mapping.yml
  13. 51.

    "autoload": { "psr-0": { "Monii\\Deal\\": "src" } } Monii\Deal\DealRepository =>

    src/Monii/Deal/DealRepository.php classpath:Monii/Deal/resources/mapping.yml => src/Monii/Deal/resources/mapping.yml classpath:Monii/Deal/resources/mapping.yml => vendor/monii/deal/src/Monii/Deal/resources/mapping.yml
  14. 55.

    $container["orm.em.options"] = [ "mappings" => [ [ "type" => "xml",

    "namespace" => "Monii\Deal", "resources_namespace" => "Monii\Deal\mappings", ], ], ];
  15. 56.

    $container["orm.em.options"] = [ "mappings" => [ [ "type" => "xml",

    "namespace" => "Monii\Deal", "resources_namespace" => "Monii\Deal\mappings", ], ], ]; Monii\Deal\Deal => classpath:Monii/Deal/mappings/Deal.xml => vendor/monii/deal/src/Monii/Deal/mappings/Deal.xml
  16. 60.
  17. 64.

    "autoload": { "psr-4": { "Monii\\Deal\\": "src" } } Monii\Deal\DealRepository =>

    src/DealRepository.php Monii\Deal\DealRepository => vendor/monii/deal/src/DealRepository.php
  18. 67.

    "autoload": { "psr-4": { "Monii\\Deal\\": "src", "Monii\\Deal\\resources": "resources" } }

    classpath:Monii/Deal/resources/mapping.yml => resources/mapping.yml
  19. 68.

    "autoload": { "psr-4": { "Monii\\Deal\\": "src", "Monii\\Deal\\resources": "resources" } }

    classpath:Monii/Deal/resources/mapping.yml => resources/mapping.yml classpath:Monii/Deal/resources/mapping.yml => vendor/monii/deal/resources/mapping.yml
  20. 71.
  21. 74.
  22. 85.

    Symfony controllers as services can be used as-is in Silex,

    Drupal, Laravel, and Symfony full stack
  23. 88.
  24. 95.
  25. 96.

    Hey! I'm trying to decide if Glide should use PSR-7

    for it's next release. — Jonathan Reinink, June 2015
  26. 99.
  27. 103.
  28. 106.
  29. 114.
  30. 115.
  31. 119.

    Think about the code you write directly into a glue

    package (It can lead to better design)
  32. 126.
  33. 130.
  34. 138.