@@ -237,66 +237,66 @@ whenever needed.
237237But what about when you deploy to production? We will need to hide those tools and
238238optimize for speed!
239239
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:
244244
245245.. configuration-block ::
246246
247- .. code-block :: yaml
247+ .. code-block :: yaml
248248
249- # config/packages/routing.yaml
249+ # config/packages/routing.yaml
250+ framework :
251+ router :
252+ utf8 : true
253+
254+ when@prod :
250255 framework :
251256 router :
252- utf8 : true
257+ strict_requirements : null
253258
254- when@prod :
255- framework :
256- router :
257- strict_requirements : null
259+ .. code-block :: xml
258260
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" >
260270
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 >
270274
275+ <when env =" prod" >
271276 <framework : config >
272- <framework : router utf8 = " true " />
277+ <framework : router strict-requirements = " null " />
273278 </framework : config >
279+ </when >
280+ </container >
274281
275- <when env =" prod" >
276- <framework : config >
277- <framework : router strict-requirements =" null" />
278- </framework : config >
279- </when >
280- </container >
282+ .. code-block :: php
281283
282- .. code-block :: php
284+ // config/packages/framework.php
285+ namespace Symfony\Component\DependencyInjection\Loader\Configurator;
283286
284- // config/packages/framework.php
285- namespace Symfony\Component\DependencyInjection\Loader\Configurator;
287+ use Symfony\Config\FrameworkConfig;
286288
287- use Symfony\Config\FrameworkConfig;
289+ return static function (FrameworkConfig $framework, ContainerConfigurator $containerConfigurator) {
290+ $framework->router()
291+ ->utf8(true)
292+ ;
288293
289- return static function (FrameworkConfig $framework, ContainerConfigurator $containerConfigurator) {
294+ if ('prod' === $containerConfigurator->env() ) {
290295 $framework->router()
291- ->utf8(true )
296+ ->strictRequirements(null )
292297 ;
293-
294- if ('prod' === $containerConfigurator->env()) {
295- $framework->router()
296- ->strictRequirements(null)
297- ;
298- }
299- };
298+ }
299+ };
300300
301301 This is a *powerful * idea: by changing one piece of configuration (the environment),
302302your app is transformed from a debugging-friendly experience to one that's optimized
0 commit comments