@@ -30,15 +30,10 @@ until you interact with the proxy in some way.
3030 In PHP versions prior to 8.0 lazy services do not support parameters with
3131 default values for built-in PHP classes (e.g. ``PDO ``).
3232
33- Installation
34- ------------
33+ .. versionadded :: 6.2
3534
36- In order to use the lazy service instantiation, you will need to install the
37- ``symfony/proxy-manager-bridge `` package:
38-
39- .. code-block :: terminal
40-
41- $ composer require symfony/proxy-manager-bridge
35+ Starting from Symfony 6.2, you don't have to install any package (e.g.
36+ ``symfony/proxy-manager-bridge ``) in order to use the lazy service instantiation.
4237
4338Configuration
4439-------------
@@ -81,32 +76,16 @@ You can mark the service as ``lazy`` by manipulating its definition:
8176 $services->set(AppExtension::class)->lazy();
8277 };
8378
79+ Once you inject the service into another service, a lazy ghost object with the
80+ same signature of the class representing the service should be injected. A lazy
81+ `ghost object `_ is an object that is created empty and that is able to initialize
82+ itself when being accessed for the first time). The same happens when calling
83+ ``Container::get() `` directly.
8484
85- Once you inject the service into another service, a virtual `proxy `_ with the
86- same signature of the class representing the service should be injected. The
87- same happens when calling ``Container::get() `` directly.
88-
89- The actual class will be instantiated as soon as you try to interact with the
90- service (e.g. call one of its methods).
91-
92- To check if your proxy works you can check the interface of the received object::
85+ To check if your lazy service works you can check the interface of the received object::
9386
9487 dump(class_implements($service));
95- // the output should include "ProxyManager\Proxy\LazyLoadingInterface"
96-
97- .. note ::
98-
99- If you don't install the `ProxyManager bridge `_ , the container will skip
100- over the ``lazy `` flag and directly instantiate the service as it would
101- normally do.
102-
103- Additional Resources
104- --------------------
105-
106- You can read more about how proxies are instantiated, generated and initialized
107- in the `documentation of ProxyManager `_.
88+ // the output should include "Symfony\Component\VarExporter\LazyGhostObjectInterface"
10889
109- .. _`ProxyManager bridge` : https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/ProxyManager
110- .. _`proxy` : https://en.wikipedia.org/wiki/Proxy_pattern
111- .. _`documentation of ProxyManager` : https://github.com/Ocramius/ProxyManager/blob/master/docs/lazy-loading-value-holder.md
90+ .. _`ghost object` : https://en.wikipedia.org/wiki/Lazy_loading#Ghost
11291.. _`final` : https://www.php.net/manual/en/language.oop5.final.php
0 commit comments