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

Advanced Service Container Utilization

Advanced Service Container Utilization

Richard Miller

June 11, 2012
Tweet

More Decks by Richard Miller

Other Decks in Programming

Transcript

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

    View Slide

  2. View Slide

  3. View Slide

  4. Getting the most from the Symfony2
    service container

    View Slide

  5. Knowing the injection
    options open to you

    View Slide

  6. You may get to inject into the constructor

    View Slide

  7. You might get to Inject into setter methods

    View Slide

  8. You may have to inject into properties

    View Slide

  9. You can integrate objects
    created by factories

    View Slide

  10. You may need to integrate a
    static factory method

    View Slide

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

    View Slide

  12. You may be dealing with a
    separate factory object

    View Slide

  13. You can also accommodate this
    with container configuration

    View Slide

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

    View Slide

  15. The wrong way with interface injection

    View Slide

  16. What is interface injection?

    View Slide

  17. How is interface injection configured?

    View Slide

  18. Why you can't use it

    View Slide

  19. The right way with parent services

    View Slide

  20. You can have parent classes to
    reduce code repetition

    View Slide

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

    View Slide

  22. You can change configuration
    independently from code

    View Slide

  23. Understanding the service container
    compilation process

    View Slide

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

    View Slide

  25. You get to load complex
    config from extensions

    View Slide

  26. Using compiler passes to respond
    to other configuration

    View Slide

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

    View Slide

  28. You need to dynamically register
    the tagged services

    View Slide

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

    View Slide

  30. Dumping the compiled container
    for performance

    View Slide

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

    View Slide

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

    View Slide

  33. Getting the most from the Symfony2
    service container

    View Slide

  34. Questions?
    @mr_r_miller
    richardmiller.co.uk

    View Slide