This course is still being released! Check back later for more chapters.

Get Notified About this Course!

We will send you messages regarding this course only
and nothing else, we promise.
You can unsubscribe anytime by emailing us at:
privacy@symfonycasts.com
> 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
  • 149 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/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!

1 Comment

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

Looking forward to this course! Thank you!

4 | Reply |

Delete comment?

Share this comment

astronaut with balloons in space

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