Contributed by Nicolas Grekas in #45512.
The service container provided by the DependencyInjection component allows you to configure the creation of objects. However, sometimes you need to apply the factory design pattern to delegate the object creation to some special object called "the factory". In Symfony 6.1 we're improving the service container to allow you to use expressions as service factories. This can help you in advanced cases such as selecting the factory based on the value of an environment variable. The syntax to use depends on the configuration format: in YAML: factory: '@=service("foo").bar()' in XML: in PHP: ->factory(expr('service("foo").bar()')) The following example shows how to select the factory to use based on the value of a configuration parameter:
# config/services.yaml
services: App\Mailer: factory: "@=parameter('some_param') ? service('some_service') : arg(0)" arguments:
- '@some_other_service'
The arg() function returns the value of arguments passed to the factory (e.g. arg(0) returns the first argument, arg(1) returns the second argument, etc.)
Sponsor the Symfony project.
Jelentkezéshez jelentkezzen be
EGYÉB POSTS Ebben a csoportban

SymfonyLive Paris 2025, conference in French language only, will take place from March 27 to 28! The schedule is currently being revealed as we go along. More details are available here. 🚨 Tod

Symfony 6.4.19 has just been released. Here is the list of the most important changes since 6.4.18:
bug #59198 [Messenger] Filter out non-consumable receivers when registering ConsumeMessagesComm

Symfony 7.2.4 has just been released. Here is the list of the most important changes since 7.2.3:
bug #59198 [Messenger] Filter out non-consumable receivers when registering ConsumeMessagesComman

SymfonyLive Paris 2025, conference in French language only, will already start in 1 month with the workshops! Have a look on the topics and join us! Schedule details are available here.
📣

A few weeks ago, I had the pleasure of announcing the formation of the Symfony UX Core Team, a dedicated group working to enhance the frontend development experience within the Symfony ecosystem. Toda

SymfonyLive Paris 2025, conference in French language only, will take place from March 27 to 28! The schedule is currently being revealed as we go along. More details are available here.
Al

This week, development activity focused on new security features. The upcoming Symfony 7.3 version added support for security voters to explain their vote, improved the IsGranted attribute to allow us