Skip to content

Commit 8efa5a9

Browse files
authored
Add example for env var processor: trim
1 parent d6ea287 commit 8efa5a9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

configuration/env_var_processors.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,43 @@ Symfony provides the following env var processors:
376376
and end of the string. This is especially useful in combination with the
377377
``file`` processor, as it'll remove newlines at the end of a file.
378378

379+
.. configuration-block::
380+
381+
.. code-block:: yaml
382+
383+
# config/services.yaml
384+
parameters:
385+
env(AUTH_FILE): '../config/auth.json'
386+
google:
387+
auth: '%env(trim:file:AUTH_FILE)%'
388+
389+
.. code-block:: xml
390+
391+
<!-- config/packages/framework.xml -->
392+
<?xml version="1.0" encoding="UTF-8" ?>
393+
<container xmlns="http://symfony.com/schema/dic/services"
394+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
395+
xmlns:framework="http://symfony.com/schema/dic/symfony"
396+
xsi:schemaLocation="http://symfony.com/schema/dic/services
397+
https://symfony.com/schema/dic/services/services-1.0.xsd
398+
http://symfony.com/schema/dic/symfony
399+
https://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
400+
401+
<parameters>
402+
<parameter key="env(AUTH_FILE)">../config/auth.json</parameter>
403+
</parameters>
404+
405+
<google auth="%env(trim:file:AUTH_FILE)%"/>
406+
</container>
407+
408+
.. code-block:: php
409+
410+
// config/packages/framework.php
411+
$container->setParameter('env(AUTH_FILE)', '../config/auth.json');
412+
$container->loadFromExtension('google', [
413+
'auth' => '%env(trim:file:AUTH_FILE)%',
414+
]);
415+
379416
.. versionadded:: 4.3
380417

381418
The ``trim`` processor was introduced in Symfony 4.3.

0 commit comments

Comments
 (0)