@@ -869,10 +869,10 @@ Autowiring Anonymous Services Inline
869
869
870
870
The ``#[AutowireInline] `` attribute was added in Symfony 7.1.
871
871
872
- Similar to how one can define anonymous services inline using configuration files,
872
+ Similar to how anonymous services can be defined inline in configuration files,
873
873
the :class: `Symfony\\ Component\\ DependencyInjection\\ Attribute\\ AutowireInline `
874
- attribute allows declaring anonymous services inline next to their corresponding
875
- arguments::
874
+ attribute allows you to declare anonymous services inline, directly next to their
875
+ corresponding arguments::
876
876
877
877
public function __construct(
878
878
#[AutowireInline(
@@ -888,11 +888,13 @@ arguments::
888
888
) {
889
889
}
890
890
891
- As you might have already figured out, this declaration instructs Symfony to inject an
892
- object created by calling the ``ScopingHttpClient::forBaseUri() `` factory with the
893
- configured base URI and default options.
891
+ This example tells Symfony to inject an object created by calling the
892
+ ``ScopingHttpClient::forBaseUri() `` factory with the specified base URI and
893
+ default options. This is just one example: you can use the ``#[AutowireInline] ``
894
+ attribute to define any kind of anonymous service.
894
895
895
- Of course, this is just an example and this attribute can be used to construct any kind of objects.
896
+ While this approach is convenient for simple service definitions, consider moving
897
+ complex or heavily configured services to a configuration file to ease maintenance.
896
898
897
899
Autowiring Controller Action Methods
898
900
------------------------------------
0 commit comments