Slide 1

Slide 1 text

Advanced Service Container Utilization by Richard Miller (@mr_r_miller)

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

Getting the most from the Symfony2 service container

Slide 5

Slide 5 text

Knowing the injection options open to you

Slide 6

Slide 6 text

You may get to inject into the constructor

Slide 7

Slide 7 text

You might get to Inject into setter methods

Slide 8

Slide 8 text

You may have to inject into properties

Slide 9

Slide 9 text

You can integrate objects created by factories

Slide 10

Slide 10 text

You may need to integrate a static factory method

Slide 11

Slide 11 text

You can configure the container to use the factory method

Slide 12

Slide 12 text

You may be dealing with a separate factory object

Slide 13

Slide 13 text

You can also accommodate this with container configuration

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

The wrong way with interface injection

Slide 16

Slide 16 text

What is interface injection?

Slide 17

Slide 17 text

How is interface injection configured?

Slide 18

Slide 18 text

Why you can't use it

Slide 19

Slide 19 text

The right way with parent services

Slide 20

Slide 20 text

You can have parent classes to reduce code repetition

Slide 21

Slide 21 text

You can also have a parent service to reduce repetitive configuration

Slide 22

Slide 22 text

You can change configuration independently from code

Slide 23

Slide 23 text

Understanding the service container compilation process

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

You get to load complex config from extensions

Slide 26

Slide 26 text

Using compiler passes to respond to other configuration

Slide 27

Slide 27 text

What if you want to use services from other bundles?

Slide 28

Slide 28 text

You need to dynamically register the tagged services

Slide 29

Slide 29 text

You can register compiler passes from bundles in the framework

Slide 30

Slide 30 text

Dumping the compiled container for performance

Slide 31

Slide 31 text

You get the performance benefits by caching the dumped container

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Getting the most from the Symfony2 service container

Slide 34

Slide 34 text

Questions? @mr_r_miller richardmiller.co.uk