Skip to content

Commit e5024a1

Browse files
committed
Add the secret documentation
1 parent 052d214 commit e5024a1

File tree

4 files changed

+454
-1
lines changed

4 files changed

+454
-1
lines changed

best_practices.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,14 @@ application behavior.
8787
:ref:`Use env vars in your project <config-env-vars>` to define these options
8888
and create multiple ``.env`` files to :ref:`configure env vars per environment <config-dot-env>`.
8989

90+
Use Secret for Sensitive Information
91+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92+
93+
These are the options used to store sensitive information like passwords,
94+
tokens, api key
95+
96+
:ref:`Use secrets <secrets-set>` to define these options in an easy and secure way.
97+
9098
Use Parameters for Application Configuration
9199
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92100

configuration/env_var_processors.rst

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,59 @@ Symfony provides the following env var processors:
624624

625625
The ``query_string`` processor was introduced in Symfony 4.3.
626626

627+
``env(secret:FOO)``
628+
Reads a secret value stored in the app's vault, :ref:`see how to set Secrets<secrets-set>`.
629+
630+
.. code-block:: terminal
631+
632+
$ php bin/console secrets:set DATABASE_PASSWORD -
633+
634+
.. configuration-block::
635+
636+
.. code-block:: yaml
637+
638+
# config/packages/database.yaml
639+
doctrine:
640+
dbal:
641+
# by convention the env var names are always uppercase
642+
url: '%env(DATABASE_URL)%'
643+
password: '%env(secret:DATABASE_PASSWORD)%'
644+
645+
.. code-block:: xml
646+
647+
<!-- config/packages/doctrine.xml -->
648+
<?xml version="1.0" encoding="UTF-8" ?>
649+
<container xmlns="http://symfony.com/schema/dic/services"
650+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
651+
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
652+
xsi:schemaLocation="http://symfony.com/schema/dic/services
653+
https://symfony.com/schema/dic/services/services-1.0.xsd
654+
http://symfony.com/schema/dic/doctrine
655+
https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">
656+
657+
<doctrine:config>
658+
<!-- by convention the env var names are always uppercase -->
659+
<doctrine:dbal url="%env(DATABASE_URL)%" password="%env(secret:DATABASE_PASSWORD)%"/>
660+
</doctrine:config>
661+
662+
</container>
663+
664+
.. code-block:: php
665+
666+
// config/packages/doctrine.php
667+
$container->loadFromExtension('doctrine', [
668+
'dbal' => [
669+
// by convention the env var names are always uppercase
670+
'url' => '%env(DATABASE_URL)%',
671+
'password' => '%env(secret:DATABASE_PASSWORD)%',
672+
]
673+
]);
674+
675+
676+
.. versionadded:: 4.4
677+
678+
The ``secret`` processor was introduced in Symfony 4.4.
679+
627680
It is also possible to combine any number of processors:
628681

629682
.. code-block:: yaml

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