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

Demystify the magic of the Dependency Injection...

Avatar for Cadien Cadien
April 04, 2025
180

Demystify the magic of the Dependency Injection Container

Symfony offer many great features that make our lives much easier. Thanks to dependency injection and service containers, for example, we never have to worry about whether a class is available somewhere.
But what has been given to us for years is actually not even a function of PHP.
But what exactly is a "container" and how exactly does it enable us to magically always have everything "available"?
In this workshop, we will not only take a detailed look at what "dependency injection" actually is.
But also what exactly a container is and to build it together step by step in order to be able to understand it even better in our frameworks in the future.

Avatar for Cadien

Cadien

April 04, 2025
Tweet

Transcript

  1. Hi, I’m Oliver Kossin – Symfony and PHP-Developer for 10

    Years – Work in Cologne at – Loves football, traveling and DIY projects https://github.com/TheCadien
  2. „Your application is full of useful objects: a "Mailer" object

    might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  3. The Star fl eet – Is an organisation – A

    List of – Ships – Star fl eet of fi cer
  4. The Star fl eet – Is an organisation – A

    List of IDs – Ships – Star fl eet of fi cer – …
  5. The Star fl eet – NCC-1701 D – SC-231-427 –

    SP-937-215 – NX-01 – NCC-1701 – NCC-74656 – 47-Alpha–612 – …
  6. „Your application is full of useful objects: a "Mailer" object

    might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  7. „Your application is full of useful objects: a "Mailer" object

    might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  8. „Your Star fl eet is full of useful objects: a

    "Mailer" object might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  9. „Your Star fl eet is full of useful objects: a

    "Mailer" object might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  10. „Your Star fl eet is full of useful Starships: a

    "Mailer" object might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  11. „Your Star fl eet is full of useful Starships: a

    "Mailer" object might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  12. „Your Star fl eet is full of useful Starships: a

    „Galaxy Class" Ship might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  13. „Your Star fl eet is full of useful Starships: a

    „Galaxy Class" Ship might help you send emails while another object might help you save things to the database. 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  14. „Your Star fl eet is full of useful Starships: a

    „Galaxy Class" Ship might help you explore the Universe!! 
 […]
 
 In Symfony, these useful objects are called services and each service lives inside a very special object called the service container“
  15. Miles O'Brien – Star fl eet Chief – Husband of

    Keiko O’Brien – Enterprise D for 6 years
  16. Miles O'Brien – Star fl eet Chief – Husband of

    Keiko O’Brien – Enterprise D for 6 years – Since 2369 on Deep Space 9
  17. Miles O'Brien – Star fl eet Chief – Husband of

    Keiko O’Brien – Enterprise D for 6 years – Since 2369 on Deep Space 9 – Work also at the De fi ant
  18. Star fl eet Command
 – Star fl eet Administration –

    Registration new Ships – Registration new Of fi cer – ..