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

Demystify Symfony - Understanding the functions...

Cadien
July 05, 2024
42

Demystify Symfony - Understanding the functions of the framework

"Demystify Symfony - Understanding the functions of the framework" -
Web Summer Camp 2024

"Symfony offers many great functions that make our lives much easier. For example, thanks to dependency injection and Service Container, we never have to worry about having a class available anywhere.
But what has been given to us for years is actually not even a function of PHP.
This and other features of the framework that we use so often. Let's take a closer look at how they work and make their magic easy to understand."

Cadien

July 05, 2024
Tweet

Transcript

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

    Years – Work in Cologne at – Loves football, traveling and DIY projects https://github.com/TheCadien
  2. – 2007: Symfony 1.0 – 2011: Symfony 2.0 (New Architecture)

    – 2015: Symfony 3.0 (Autowiring) – 2017: Symfony 4.0 (SymfonyFlex)
  3. – 2007: Symfony 1.0 – 2011: Symfony 2.0 (New Architecture)

    – 2015: Symfony 3.0 (Autowiring) – 2017: Symfony 4.0 (SymfonyFlex) – 2019: Symfony 5.0
  4. – 2007: Symfony 1.0 – 2011: Symfony 2.0 (New Architecture)

    – 2015: Symfony 3.0 (Autowiring) – 2017: Symfony 4.0 (SymfonyFlex) – 2019: Symfony 5.0 – 2021: Symfony 6.0
  5. – 2007: Symfony 1.0 – 2011: Symfony 2.0 (New Architecture)

    – 2015: Symfony 3.0 (Autowiring) – 2017: Symfony 4.0 (SymfonyFlex) – 2019: Symfony 5.0 – 2021: Symfony 6.0 – 2023: Symfony 7.0 (PHP Attributes)
  6. – 2007: Symfony 1.0 – 2011: Symfony 2.0 (New Architecture)

    – 2015: Symfony 3.0 (Autowiring) – 2017: Symfony 4.0 (SymfonyFlex) – 2019: Symfony 5.0 – 2021: Symfony 6.0 – 2023: Symfony 7.0 (PHP Attributes) – 2025: Symfony 8.0
  7. – Patches are released every month, security fi xes immediately

    – Minor versions twice a year (Next Minor Release November 2024) – Major versions every other year 7.1.2
  8. Con fi g, Console, DependencyInjection, DotEnv, ErrorHandler, EventDispatcher, Form, Security,

    HttpFoundation, HttpKernel , Mailer, Noti fi er, Messenger, Process, Routing, Serializer, Work fl ow, Yaml ….
  9. „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“
  10. The Star fl eet – Is an organisation – A

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

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

    SP-937-215 – NX-01 – NCC-1701 – NCC-74656 – 47-Alpha–612 – …
  13. „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“
  14. „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“
  15. „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“
  16. „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“
  17. „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“
  18. „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“
  19. „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“
  20. „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“
  21. „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“
  22. Task: Build a method „make“ which takes over the instantiation

    of the class, with constructor properties
  23. Task: Extend the „make“ method so that external dependencies such

    as the con fi guration of the „name“ can be passed in.
  24. Miles O'Brien – Star fl eet Chief – Husband of

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

    Keiko O’Brien – Enterprise D for 6 years – Since 2369 on Deep Space 9
  26. 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
  27. Task: Set a newly instantiated service with a new ID

    and use it again if a service of the same instance already exists.
  28. Star fl eet Command
 – Star fl eet Administration –

    Registration new Ships – Registration new Of fi cer – ..
  29. Build a new class "Star fl eetCommand" to inherit Star

    fl eet. (Like our Con fi g example) Afterwards the Star fl eet should be refactored, so that only the 3 methods "get", „has" and "set" are left. Everything else will be moved to the Star fl eet Command. New services should now be "registered" via the SC. Task: