@@ -41,6 +41,8 @@ In order to use the lazy service instantiation, you will need to install the
4141
4242 $ composer require symfony/proxy-manager-bridge
4343
44+ .. _lazy-services_configuration :
45+
4446Configuration
4547-------------
4648
@@ -101,6 +103,26 @@ To check if your proxy works you can check the interface of the received object:
101103 over the ``lazy `` flag and directly instantiate the service as it would
102104 normally do.
103105
106+ You can also configure your service's laziness thanks to the
107+ :class: `Symfony\\ Component\\ DependencyInjection\\ Attribute\\ Autoconfigure ` attribute.
108+ For example, to define your service as lazy use the following::
109+
110+ namespace App\Twig;
111+
112+ use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
113+ use Twig\Extension\ExtensionInterface;
114+
115+ #[Autoconfigure(lazy: true)]
116+ class AppExtension implements ExtensionInterface
117+ {
118+ // ...
119+ }
120+
121+ ..versionadded ::5.4
122+
123+ The:class: `Symfony\\ Component\\ DependencyInjection\\ Attribute\\ Autoconfigure ` attribute
124+ was introduced in Symfony 5.4.
125+
104126Interface Proxifying
105127--------------------
106128
@@ -159,6 +181,27 @@ specific interfaces.
159181 ;
160182 };
161183
184+ Just like in the:ref: `Configuration <lazy-services_configuration >` section, you can
185+ use the:class: `Symfony\\ Component\\ DependencyInjection\\ Attribute\\ Autoconfigure `
186+ attribute to configure the interface to proxify by passing its FQCN as the ``lazy ``
187+ parameter value::
188+
189+ namespace App\Twig;
190+
191+ use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
192+ use Twig\Extension\ExtensionInterface;
193+
194+ #[Autoconfigure(lazy: ExtensionInterface::class)]
195+ class AppExtension implements ExtensionInterface
196+ {
197+ // ...
198+ }
199+
200+ ..versionadded ::5.4
201+
202+ The:class: `Symfony\\ Component\\ DependencyInjection\\ Attribute\\ Autoconfigure ` attribute
203+ was introduced in Symfony 5.4.
204+
162205The virtual `proxy `_ injected into other services will only implement the
163206specified interfaces and will not extend the original service class, allowing to
164207lazy load services using `final `_ classes. You can configure the proxy to