@@ -12,6 +12,7 @@ application there could be more tags available provided by third-party bundles:
1212Tag Name Usage
1313======================================== ========================================================================
1414`auto_alias `_ Define aliases based on the value of container parameters
15+ `assets.package `_ Add an asset package
1516`console.command `_ Add a command
1617`container.hot_path `_ Add to list of always needed services
1718`container.no_preload `_ Remove a class from the list of classes preloaded by PHP
@@ -50,6 +51,53 @@ Tag Name Usage
5051`validator.initializer `_ Register a service that initializes objects before validation
5152======================================== ========================================================================
5253
54+ assets.package
55+ --------------
56+
57+ **Purpose **: Add an asset package to the application
58+
59+ This is an alternative way to declare a package in :doc: `/components/asset `.
60+ The `package ` attribute of the tag is required to name the package.
61+
62+ .. configuration-block ::
63+
64+ .. code-block :: yaml
65+
66+ services :
67+ App\Assets\AvatarPackage :
68+ tags :
69+ - { name: assets.package, package: avatar }
70+
71+ .. code-block :: xml
72+
73+ <?xml version =" 1.0" encoding =" UTF-8" ?>
74+ <container xmlns =" http://symfony.com/schema/dic/services"
75+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
76+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
77+ https://symfony.com/schema/dic/services/services-1.0.xsd" >
78+
79+ <services >
80+ <service id =" App\Assets\AvatarPackage" >
81+ <tag name =" assets.package" package =" avatar" />
82+ </service >
83+ </services >
84+ </container >
85+
86+ .. code-block :: php
87+
88+ use App\Assets\AvatarPackage;
89+
90+ $container
91+ ->register(AvatarPackage::class)
92+ ->addTag('assets.package', ['package' => 'avatar'])
93+ ;
94+
95+ Now you can use the ``avatars `` package in your templates:
96+
97+ .. code-block :: html+twig
98+
99+ <img src="{{ asset('...', 'avatars') }}">
100+
53101auto_alias
54102----------
55103
0 commit comments