@@ -14,6 +14,8 @@ Tag Name Usage
1414`auto_alias `_ Define aliases based on the value of container parameters
1515`console.command `_ Add a command
1616`container.hot_path `_ Add to list of always needed services
17+ `container.no_preload `_ Remove a class from the list of classes preloaded by PHP
18+ `container.preload `_ Add some class to the list of classes preloaded by PHP
1719`controller.argument_value_resolver `_ Register a value resolver for controller arguments such as ``Request ``
1820`data_collector `_ Create a class that collects custom data for the profiler
1921`doctrine.event_listener `_ Add a Doctrine event listener
@@ -212,6 +214,109 @@ for services and their class hierarchy. The result is as significant performance
212214
213215Use this tag with great caution, you have to be sure that the tagged service is always used.
214216
217+ .. _dic-tags-container-nopreload :
218+
219+ container.no_preload
220+ --------------------
221+
222+ **Purpose **: Remove a class from the list of classes preloaded by PHP
223+
224+ .. versionadded :: 5.1
225+
226+ The ``container.no_preload `` tag was introduced in Symfony 5.1.
227+
228+ Add this tag to a service and its class won't be preloaded when using
229+ `PHP class preloading `_:
230+
231+ .. configuration-block ::
232+
233+ .. code-block :: yaml
234+
235+ services :
236+ App\SomeNamespace\SomeService :
237+ tags : ['container.no_preload']
238+
239+ .. code-block :: xml
240+
241+ <?xml version =" 1.0" encoding =" UTF-8" ?>
242+ <container xmlns =" http://symfony.com/schema/dic/services"
243+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
244+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
245+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
246+
247+ <services >
248+ <service id =" App\SomeNamespace\SomeService" >
249+ <tag name =" container.no_preload" />
250+ </service >
251+ </services >
252+ </container >
253+
254+ .. code-block :: php
255+
256+ use App\SomeNamespace\SomeService;
257+
258+ $container
259+ ->register(SomeService::class)
260+ ->addTag('container.no_preload')
261+ ;
262+
263+ .. _dic-tags-container-preload :
264+
265+ container.preload
266+ -----------------
267+
268+ **Purpose **: Add some class to the list of classes preloaded by PHP
269+
270+ .. versionadded :: 5.1
271+
272+ The ``container.preload `` tag was introduced in Symfony 5.1.
273+
274+ When using `PHP class preloading `_, this tag allows you to define which PHP
275+ classes should be preloaded. This can improve performance by making some of the
276+ classes used by your service always available for all requests (until the server
277+ is restarted):
278+
279+ .. configuration-block ::
280+
281+ .. code-block :: yaml
282+
283+ services :
284+ App\SomeNamespace\SomeService :
285+ tags :
286+ - { name: 'container.preload', class: 'App\SomeClass' }
287+ - { name: 'container.preload', class: 'App\Some\OtherClass' }
288+ # ...
289+
290+ .. code-block :: xml
291+
292+ <?xml version =" 1.0" encoding =" UTF-8" ?>
293+ <container xmlns =" http://symfony.com/schema/dic/services"
294+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
295+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
296+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
297+
298+ <services >
299+ <service id =" App\SomeNamespace\SomeService" >
300+ <tag name =" container.preload" class =" App\SomeClass" />
301+ <tag name =" container.preload" class =" App\Some\OtherClass" />
302+ <!-- ... -->
303+ </service >
304+ </services >
305+ </container >
306+
307+ .. code-block :: php
308+
309+ use App\Some\OtherClass;
310+ use App\SomeClass;
311+ use App\SomeNamespace\SomeService;
312+
313+ $container
314+ ->register(SomeService::class)
315+ ->addTag('container.preload', ['class' => SomeClass::class)
316+ ->addTag('container.preload', ['class' => OtherClass::class)
317+ // ...
318+ ;
319+
215320 controller.argument_value_resolver
216321----------------------------------
217322
@@ -1214,3 +1319,4 @@ Bridge.
12141319.. _`Twig's documentation` : https://twig.symfony.com/doc/2.x/advanced.html#creating-an-extension
12151320.. _`SwiftMailer's Plugin Documentation` : https://swiftmailer.symfony.com/docs/plugins.html
12161321.. _`Twig Loader` : https://twig.symfony.com/doc/2.x/api.html#loaders
1322+ .. _`PHP class preloading` : https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.preload
0 commit comments