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

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!

Beau Simensen

November 23, 2015
Tweet

More Decks by Beau Simensen

Other Decks in Programming

Transcript

  1. Symfony handled this by convention (this is one reason why

    so many projects ship everything as a bundle)
  2. Won't work if the mappings live in a project other

    than a bundle* * Nasty __DIR__ hacks don't count.
  3. "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
  4. What if we used PSR-0 mappings and rules to locate

    other types of files than just classes?
  5. "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
  6. "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
  7. $container["orm.em.options"] = [ "mappings" => [ [ "type" => "xml",

    "namespace" => "Monii\Deal", "resources_namespace" => "Monii\Deal\mappings", ], ], ];
  8. $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
  9. "autoload": { "psr-4": { "Monii\\Deal\\": "src" } } Monii\Deal\DealRepository =>

    src/DealRepository.php Monii\Deal\DealRepository => vendor/monii/deal/src/DealRepository.php
  10. "autoload": { "psr-4": { "Monii\\Deal\\": "src", "Monii\\Deal\\resources": "resources" } }

    classpath:Monii/Deal/resources/mapping.yml => resources/mapping.yml
  11. "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
  12. Symfony controllers as services can be used as-is in Silex,

    Drupal, Laravel, and Symfony full stack
  13. Hey! I'm trying to decide if Glide should use PSR-7

    for it's next release. — Jonathan Reinink, June 2015
  14. Think about the code you write directly into a glue

    package (It can lead to better design)