Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3ff812d

Browse filesBrowse files
bpolaszekOskarStark
authored andcommitted
[DependencyInjection] Negated (not:) env var processor
1 parent 1839389 commit 3ff812d
Copy full SHA for 3ff812d

File tree

1 file changed

+40
-0
lines changed
Filter options

1 file changed

+40
-0
lines changed

‎configuration/env_var_processors.rst

Copy file name to clipboardExpand all lines: configuration/env_var_processors.rst
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,46 @@ Symfony provides the following env var processors:
136136
'http_method_override' => '%env(bool:HTTP_METHOD_OVERRIDE)%',
137137
]);
138138
139+
``env(not:FOO)``
140+
141+
.. versionadded:: 5.3
142+
143+
The ``not:`` env var processor was introduced in Symfony 5.3.
144+
145+
Casts ``FOO`` to a bool (just as ``env(bool:...)`` does) except it returns the inverted value
146+
(falsy values are returned as ``true``, truthy values are returned as ``false``):
147+
148+
.. configuration-block::
149+
150+
.. code-block:: yaml
151+
152+
# config/services.yaml
153+
parameters:
154+
safe_for_production: '%env(not:APP_DEBUG)%'
155+
156+
.. code-block:: xml
157+
158+
<!-- config/services.xml -->
159+
<?xml version="1.0" encoding="UTF-8" ?>
160+
<container xmlns="http://symfony.com/schema/dic/services"
161+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
162+
xmlns:framework="http://symfony.com/schema/dic/symfony"
163+
xsi:schemaLocation="http://symfony.com/schema/dic/services
164+
https://symfony.com/schema/dic/services/services-1.0.xsd
165+
http://symfony.com/schema/dic/symfony
166+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
167+
168+
<parameters>
169+
<parameter key="safe_for_production">%env(not:APP_DEBUG)%</parameter>
170+
</parameters>
171+
172+
</container>
173+
174+
.. code-block:: php
175+
176+
// config/services.php
177+
$container->setParameter('safe_for_production', '%env(not:APP_DEBUG)%');
178+
139179
``env(int:FOO)``
140180
Casts ``FOO`` to an int.
141181

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.