Skip to content

Commit c904191

Browse files
committed
Add examples for parameter processors
1 parent a7d5206 commit c904191

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

configuration/external_parameters.rst

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,26 @@ you will want to have specific types so that they match the types expected by yo
143143
144144
A number of different types are supported:
145145

146-
``env(string):FOO)``
146+
``env(string:FOO)``
147147
Casts ``FOO`` to a string
148+
149+
.. code-block:: php
150+
151+
parameters:
152+
env(SECRET): "some_secret"
153+
framework:
154+
secret: '%env(string:SECRET)%'
148155
149156
``env(bool:FOO)``
150157
Casts ``FOO`` to a bool
151158

159+
.. code-block:: php
160+
161+
parameters:
162+
env(HTTP_METHOD_OVERRIDE): "true"
163+
framework:
164+
http_method_override: '%env(bool:HTTP_METHOD_OVERRIDE)%'
165+
152166
``env(int:FOO)``
153167
Casts ``FOO`` to an int
154168

@@ -158,26 +172,70 @@ A number of different types are supported:
158172
``env(const:FOO)``
159173
Finds the const value named in ``FOO``
160174

175+
.. code-block:: php
176+
177+
parameters:
178+
env(HEALTH_CHECK_METHOD): "Symfony\Component\HttpFoundation\Request:METHOD_HEAD"
179+
security:
180+
access_control:
181+
- { path: '^/health-check$', methods: '%env(const:HEALTH_CHECK_METHOD)%' }
182+
161183
``env(base64:FOO)``
162184
Decodes ``FOO`` that is a base64 encoded string
163185

164186
``env(json:FOO)``
165187
Decodes ``FOO`` that is a json encoded string into either an array or ``null``
188+
189+
.. code-block:: php
190+
191+
parameters:
192+
env(TRUSTED_HOSTS): "['10.0.0.1', '10.0.0.2']"
193+
framework:
194+
trusted_hosts: '%env(json:TRUSTED_HOSTS)%'
166195
167196
``env(resolve:FOO)``
168197
Resolves references in the string ``FOO`` to other parameters
198+
199+
.. code-block:: php
200+
201+
parameters:
202+
env(HOST): '10.0.0.1'
203+
env(SENTRY_DSN): "http://%env(HOST)%/project"
204+
sentry:
205+
dsn: '%env(resolve:SENTRY_DSN)%'
169206
170207
``env(csv:FOO)``
171208
Decodes ``FOO`` that is a single row of comma seperated values
172209

210+
.. code-block:: php
211+
212+
parameters:
213+
env(TRUSTED_HOSTS): "10.0.0.1, 10.0.0.2"
214+
framework:
215+
trusted_hosts: '%env(csv:TRUSTED_HOSTS)%'
216+
173217
``env(file:FOO)``
174218
Reads the contents of a file named in ``FOO``
219+
220+
.. code-block:: php
221+
222+
parameters:
223+
env(AUTH_FILE): "auth.json"
224+
google:
225+
auth: '%env(file:AUTH_FILE)%'
175226
176227
It is also possible to combine the processors:
177228

178229
``env(json:file:FOO)``
179230
Reads the contents of a file named in ``FOO``, and then decode it from json, resulting in an array or ``null``
180231

232+
.. code-block:: php
233+
234+
parameters:
235+
env(AUTH_FILE): "%kernel.root%/auth.json"
236+
google:
237+
auth: '%env(file:resolve:AUTH_FILE)%'
238+
181239
182240
.. _configuration-env-var-in-prod:
183241

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy