@@ -143,12 +143,26 @@ you will want to have specific types so that they match the types expected by yo
143
143
144
144
A number of different types are supported:
145
145
146
- ``env(string) :FOO) ``
146
+ ``env(string:FOO) ``
147
147
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)%'
148
155
149
156
``env(bool:FOO) ``
150
157
Casts ``FOO `` to a bool
151
158
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
+
152
166
``env(int:FOO) ``
153
167
Casts ``FOO `` to an int
154
168
@@ -158,26 +172,70 @@ A number of different types are supported:
158
172
``env(const:FOO) ``
159
173
Finds the const value named in ``FOO ``
160
174
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
+
161
183
``env(base64:FOO) ``
162
184
Decodes ``FOO `` that is a base64 encoded string
163
185
164
186
``env(json:FOO) ``
165
187
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)%'
166
195
167
196
``env(resolve:FOO) ``
168
197
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)%'
169
206
170
207
``env(csv:FOO) ``
171
208
Decodes ``FOO `` that is a single row of comma seperated values
172
209
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
+
173
217
``env(file:FOO) ``
174
218
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)%'
175
226
176
227
It is also possible to combine the processors:
177
228
178
229
``env(json:file:FOO) ``
179
230
Reads the contents of a file named in ``FOO ``, and then decode it from json, resulting in an array or ``null ``
180
231
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
+
181
239
182
240
.. _configuration-env-var-in-prod :
183
241
0 commit comments