> Symfony 7 >

Course Overview

Login to bookmark this course

Inyección de dependencias #[Attributes]

In modern Symfony, services can be configured using native PHP attributes, integrating configuration directly within the code. Let’s explore this with a practical example.

  • intermediate
  • 377 students
  • EN/ES Captions
  • EN/ES Script
  • Certificate of Completion

Your Guides

About this course

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": ">=8.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "symfony/console": "7.1.*", // v7.1.3
        "symfony/dotenv": "7.1.*", // v7.1.3
        "symfony/flex": "^2", // v2.4.6
        "symfony/framework-bundle": "7.1.*", // v7.1.3
        "symfony/mailer": "7.1.*", // v7.1.5
        "symfony/monolog-bundle": "^3.0", // v3.10.0
        "symfony/runtime": "7.1.*", // v7.1.1
        "symfony/string": "7.1.*", // v7.1.3
        "symfony/twig-bundle": "7.1.*", // v7.1.1
        "symfony/ux-icons": "^2.18", // v2.19.0
        "symfony/ux-twig-component": "^2.18", // v2.19.0
        "symfony/yaml": "7.1.*", // v7.1.1
        "twig/extra-bundle": "^2.12|^3.0", // v3.11.0
        "twig/string-extra": "^3.10", // v3.11.0
        "twig/twig": "^2.12|^3.0" // v3.11.0
    },
    "require-dev": {
        "symfony/debug-bundle": "7.1.*", // v7.1.1
        "symfony/stopwatch": "7.1.*", // v7.1.1
        "symfony/web-profiler-bundle": "7.1.*" // v7.1.3
    }
}

Tradicionalmente, los servicios Symfony se configuraban en archivos XML o YAML. Esto crea un poco de desconexión entre tu código y la configuración. En el Symfony moderno, podemos utilizar atributos nativos de PHP para configurar los servicios. Esto nos permite mantener la configuración de nuestro servicio directamente en nuestro código como metadatos nativos de PHP, ¡lo que es bastante genial! Vamos a sumergirnos en estos atributos de Inyección de Dependencia en el contexto de un ejemplo divertido.

Next courses in the Symfony 7: Learn More Tricks section of the Symfony 7 Track!

3 Comments

Sort By
Login or Register to join the conversation
Jared avatar Jared 3 months ago

Looking forward to this course! Thank you!

4 | Reply |
Braunstetter avatar Braunstetter 10 days ago

Thank you very much for this course. I love these courses that go beyond the fundamentals. And the new speaker is also great, although of course I miss Ryan.

| Reply |

Thanks for your feedback! That sounds like we are moving in the right direction.

Stay safe and happy coding! Cheers!

| Reply |

Delete comment?

Share this comment

astronaut with balloons in space

"Houston: no signs of life"
Start the conversation!