File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -171,6 +171,25 @@ In a Symfony bundle, call this method in the ``load()`` method of the
171171 }
172172 }
173173
174+ or if you are following the recommended way for new bundles and for bundles following the
175+ :ref: `recommended directory structure <bundles-directory-structure >`::
176+
177+ // ...
178+ use Symfony\Component\DependencyInjection\ContainerBuilder;
179+ use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
180+ use Symfony\Component\HttpKernel\Bundle\AbstractBundle;
181+
182+ class MyBundle extends AbstractBundle
183+ {
184+ public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
185+ {
186+ $builder
187+ ->registerForAutoconfiguration(CustomInterface::class)
188+ ->addTag('app.custom_tag')
189+ ;
190+ }
191+ }
192+
174193Autoconfiguration registering is not limited to interfaces. It is possible
175194to use PHP attributes to autoconfigure services by using the
176195:method: `Symfony\\ Component\\ DependencyInjection\\ ContainerBuilder::registerAttributeForAutoconfiguration `
You can’t perform that action at this time.
0 commit comments