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

Advanced Service Container Utilization

Advanced Service Container Utilization

Ab44158da0498db70754ee8061e69c31?s=128

Richard Miller

June 11, 2012
Tweet

Transcript

  1. Advanced Service Container Utilization by Richard Miller (@mr_r_miller)

  2. None
  3. None
  4. Getting the most from the Symfony2 service container

  5. Knowing the injection options open to you

  6. You may get to inject into the constructor

  7. You might get to Inject into setter methods

  8. You may have to inject into properties

  9. You can integrate objects created by factories

  10. You may need to integrate a static factory method

  11. You can configure the container to use the factory method

  12. You may be dealing with a separate factory object

  13. You can also accommodate this with container configuration

  14. Saving time by reducing the amount of configuration you have

    to write
  15. The wrong way with interface injection

  16. What is interface injection?

  17. How is interface injection configured?

  18. Why you can't use it

  19. The right way with parent services

  20. You can have parent classes to reduce code repetition

  21. You can also have a parent service to reduce repetitive

    configuration
  22. You can change configuration independently from code

  23. Understanding the service container compilation process

  24. You need to call compile if using the component outside

    the framework
  25. You get to load complex config from extensions

  26. Using compiler passes to respond to other configuration

  27. What if you want to use services from other bundles?

  28. You need to dynamically register the tagged services

  29. You can register compiler passes from bundles in the framework

  30. Dumping the compiled container for performance

  31. You get the performance benefits by caching the dumped container

  32. You get convenience as well by avoiding the cache in

    debug mode
  33. Getting the most from the Symfony2 service container

  34. Questions? @mr_r_miller richardmiller.co.uk