@@ -237,66 +237,66 @@ whenever needed.
237
237
But what about when you deploy to production? We will need to hide those tools and
238
238
optimize for speed!
239
239
240
- This is solved by Symfony's *environment * system and there are three environments a
241
- typical Symfony application begins with : ``dev ``, ``prod ``, and ``test ``. You can define
242
- options for specific environments in the configuration files from the ``config/ ``
243
- directory using the special ``when `` keyword:
240
+ This is solved by Symfony's *environment * system. Symfony applications begin with
241
+ three environments : ``dev ``, ``prod ``, and ``test ``. You can define options for
242
+ specific environments in the configuration files from the ``config/ `` directory
243
+ using the special ``when@ `` keyword:
244
244
245
245
.. configuration-block ::
246
246
247
- .. code-block :: yaml
247
+ .. code-block :: yaml
248
248
249
- # config/packages/routing.yaml
249
+ # config/packages/routing.yaml
250
+ framework :
251
+ router :
252
+ utf8 : true
253
+
254
+ when@prod :
250
255
framework :
251
256
router :
252
- utf8 : true
257
+ strict_requirements : null
253
258
254
- when@prod :
255
- framework :
256
- router :
257
- strict_requirements : null
259
+ .. code-block :: xml
258
260
259
- .. code-block :: xml
261
+ <!-- config/packages/framework.xml -->
262
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
263
+ <container xmlns =" http://symfony.com/schema/dic/services"
264
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
265
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
266
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
267
+ https://symfony.com/schema/dic/services/services-1.0.xsd
268
+ http://symfony.com/schema/dic/symfony
269
+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
260
270
261
- <!-- config/packages/framework.xml -->
262
- <?xml version =" 1.0" encoding =" UTF-8" ?>
263
- <container xmlns =" http://symfony.com/schema/dic/services"
264
- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
265
- xmlns : framework =" http://symfony.com/schema/dic/symfony"
266
- xsi : schemaLocation =" http://symfony.com/schema/dic/services
267
- https://symfony.com/schema/dic/services/services-1.0.xsd
268
- http://symfony.com/schema/dic/symfony
269
- https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
271
+ <framework : config >
272
+ <framework : router utf8 =" true" />
273
+ </framework : config >
270
274
275
+ <when env =" prod" >
271
276
<framework : config >
272
- <framework : router utf8 = " true " />
277
+ <framework : router strict-requirements = " null " />
273
278
</framework : config >
279
+ </when >
280
+ </container >
274
281
275
- <when env =" prod" >
276
- <framework : config >
277
- <framework : router strict-requirements =" null" />
278
- </framework : config >
279
- </when >
280
- </container >
282
+ .. code-block :: php
281
283
282
- .. code-block :: php
284
+ // config/packages/framework.php
285
+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
283
286
284
- // config/packages/framework.php
285
- namespace Symfony\Component\DependencyInjection\Loader\Configurator;
287
+ use Symfony\Config\FrameworkConfig;
286
288
287
- use Symfony\Config\FrameworkConfig;
289
+ return static function (FrameworkConfig $framework, ContainerConfigurator $containerConfigurator) {
290
+ $framework->router()
291
+ ->utf8(true)
292
+ ;
288
293
289
- return static function (FrameworkConfig $framework, ContainerConfigurator $containerConfigurator) {
294
+ if ('prod' === $containerConfigurator->env() ) {
290
295
$framework->router()
291
- ->utf8(true )
296
+ ->strictRequirements(null )
292
297
;
293
-
294
- if ('prod' === $containerConfigurator->env()) {
295
- $framework->router()
296
- ->strictRequirements(null)
297
- ;
298
- }
299
- };
298
+ }
299
+ };
300
300
301
301
This is a *powerful * idea: by changing one piece of configuration (the environment),
302
302
your app is transformed from a debugging-friendly experience to one that's optimized
0 commit comments