@@ -163,14 +163,21 @@ Now it looks like this::
163163 protected function configureContainer(ContainerConfigurator $c): void
164164 {
165165 $c->import(__DIR__.'/../config/framework.yaml');
166- $c->import(__DIR__.'/../config/web_profiler.yaml');
167166
168167 // register all classes in /src/ as service
169168 $c->services()
170169 ->load('App\\', __DIR__.'/*')
171170 ->autowire()
172171 ->autoconfigure()
173172 ;
173+
174+ // configure WebProfilerBundle only if the bundle is enabled
175+ if (isset($this->bundles['WebProfilerBundle'])) {
176+ $c->extension('web_profiler', [
177+ 'toolbar' => true,
178+ 'intercept_redirects' => false,
179+ ]);
180+ }
174181 }
175182
176183 protected function configureRoutes(RoutingConfigurator $routes): void
@@ -229,11 +236,15 @@ add a service conditionally based on the ``foo`` value::
229236 public function loadExtension(array $config, ContainerConfigurator $container, ContainerBuilder $builder): void
230237 {
231238 if ($config['foo']) {
232- $container->set('foo_service', new stdClass());
239+ $container->set('foo_service', new \ stdClass());
233240 }
234241 }
235242 }
236243
244+ .. versionadded :: 6.1
245+
246+ The ``AbstractExtension `` class is introduced in Symfony 6.1.
247+
237248Unlike the previous kernel, this loads an external ``config/framework.yaml `` file,
238249because the configuration started to get bigger:
239250
@@ -274,46 +285,6 @@ because the configuration started to get bigger:
274285 ;
275286 };
276287
277- As well as the ``config/web_profiler.yaml `` file:
278-
279- .. configuration-block ::
280-
281- .. code-block :: yaml
282-
283- # config/web_profiler.yaml
284- when@dev :
285- web_profiler :
286- toolbar : true
287- intercept_redirects : false
288-
289- .. code-block :: xml
290-
291- <!-- config/web_profiler.xml -->
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- xmlns : framework =" http://symfony.com/schema/dic/symfony"
296- xsi : schemaLocation =" http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd
297- http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
298-
299- <!-- WebProfilerBundle is enabled only in the "dev" environment -->
300- <when env =" dev" >
301- <web-profiler : config toolbar =" true" intercept-redirects =" false" />
302- </when >
303- </container >
304-
305- .. code-block :: php
306-
307- // config/web_profiler.php
308- use Symfony\Config\WebProfilerConfig;
309-
310- return static function (WebProfilerConfig $webProfiler) {
311- $webProfiler
312- ->toolbar(true)
313- ->interceptRedirects(false)
314- ;
315- };
316-
317288 This also loads annotation routes from an ``src/Controller/ `` directory, which
318289has one file in it::
319290
0 commit comments