1 of 6

IoC and Symfony-2 Service container

Organise your Web App better!!

Leo Lara @

2 of 6

About me

  • Leo Lara (Software Engineer / Entrepreneur)
  • Wrote first program at 8 yr old
  • Always interested in computers
  • Particularly in Internet Tech and Scalability
  • Worked at ARM (μP designer) on Server
    • Ported Facebook's HipHop compiler to ARM
    • Ported Intel Threading Building Blocks to ARM
  • Co-founder

3 of 6

Inversion of Control and Depedency Injection

  • IoC is a technique to decouple parts of an application
  • DI is a specific way of doing it
  • Terminology: services

4 of 6

The problem

Go to gist

5 of 6

Symfony 2 Service Container

  • Dependency injection
  • Configuration management
  • Extensions
  • It is a central part of Symfony 2 framewrok
  • Can be used independently
  • Enables decoupling of Symfony 2 Component
  • Configured in YAML, XML and PHP
  • Compiles to a PHP class

6 of 6

DI nirvana

  • Any object that either:
    • long lived
    • shared between different objects
    • have complex configuration
    • have complex dependencies
    • no only Symfony stuff*
  • Move code from the controller and the views to services
  • Single responsability
  • Many little components brough up by the service container