@@ -44,11 +44,13 @@ processor to turn the value of the ``HTTP_PORT`` env var into an integer:
44
44
.. code-block :: php
45
45
46
46
// config/packages/framework.php
47
- $container->loadFromExtension('framework', [
48
- 'router' => [
49
- 'http_port' => '%env(int:HTTP_PORT)%',
50
- ],
51
- ]);
47
+ use Symfony\Config\FrameworkConfig;
48
+
49
+ return static function (FrameworkConfig $framework) {
50
+ $framework->router()
51
+ ->httpPort('%env(int:HTTP_PORT)%')
52
+ ;
53
+ };
52
54
53
55
Built-In Environment Variable Processors
54
56
----------------------------------------
@@ -90,10 +92,13 @@ Symfony provides the following env var processors:
90
92
.. code-block :: php
91
93
92
94
// config/packages/framework.php
93
- $container->setParameter('env(SECRET)', 'some_secret');
94
- $container->loadFromExtension('framework', [
95
- 'secret' => '%env(string:SECRET)%',
96
- ]);
95
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
96
+ use Symfony\Config\FrameworkConfig;
97
+
98
+ return static function (ContainerBuilder $container, FrameworkConfig $framework) {
99
+ $container->setParameter('env(SECRET)', 'some_secret');
100
+ $framework->secret('%env(string:SECRET)%');
101
+ };
97
102
98
103
``env(bool:FOO) ``
99
104
Casts ``FOO `` to a bool (``true `` values are ``'true' ``, ``'on' ``, ``'yes' ``
@@ -131,10 +136,13 @@ Symfony provides the following env var processors:
131
136
.. code-block :: php
132
137
133
138
// config/packages/framework.php
134
- $container->setParameter('env(HTTP_METHOD_OVERRIDE)', 'true');
135
- $container->loadFromExtension('framework', [
136
- 'http_method_override' => '%env(bool:HTTP_METHOD_OVERRIDE)%',
137
- ]);
139
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
140
+ use Symfony\Config\FrameworkConfig;
141
+
142
+ return static function (ContainerBuilder $container, FrameworkConfig $framework) {
143
+ $container->setParameter('env(HTTP_METHOD_OVERRIDE)', 'true');
144
+ $framework->httpMethodOverride('%env(bool:HTTP_METHOD_OVERRIDE)%');
145
+ };
138
146
139
147
``env(not:FOO) ``
140
148
@@ -269,10 +277,13 @@ Symfony provides the following env var processors:
269
277
.. code-block :: php
270
278
271
279
// config/packages/framework.php
272
- $container->setParameter('env(TRUSTED_HOSTS)', '["10.0.0.1", "10.0.0.2"]');
273
- $container->loadFromExtension('framework', [
274
- 'trusted_hosts' => '%env(json:TRUSTED_HOSTS)%',
275
- ]);
280
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
281
+ use Symfony\Config\FrameworkConfig;
282
+
283
+ return static function (ContainerBuilder $container, FrameworkConfig $framework) {
284
+ $container->setParameter('env(TRUSTED_HOSTS)', '["10.0.0.1", "10.0.0.2"]');
285
+ $framework->trustedHosts('%env(json:TRUSTED_HOSTS)%');
286
+ };
276
287
277
288
``env(resolve:FOO) ``
278
289
If the content of ``FOO `` includes container parameters (with the syntax
@@ -353,10 +364,13 @@ Symfony provides the following env var processors:
353
364
.. code-block :: php
354
365
355
366
// config/packages/framework.php
356
- $container->setParameter('env(TRUSTED_HOSTS)', '10.0.0.1,10.0.0.2');
357
- $container->loadFromExtension('framework', [
358
- 'trusted_hosts' => '%env(csv:TRUSTED_HOSTS)%',
359
- ]);
367
+ use Symfony\Component\DependencyInjection\ContainerBuilder;
368
+ use Symfony\Config\FrameworkConfig;
369
+
370
+ return static function (ContainerBuilder $container, FrameworkConfig $framework) {
371
+ $container->setParameter('env(TRUSTED_HOSTS)', '10.0.0.1,10.0.0.2');
372
+ $framework->trustedHosts('%env(csv:TRUSTED_HOSTS)%');
373
+ };
360
374
361
375
``env(file:FOO) ``
362
376
Returns the contents of a file whose path is the value of the ``FOO `` env var:
0 commit comments