Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add the secret documentation
  • Loading branch information
jderusse committed Oct 18, 2019
commit e5024a1b3629a2a23140cfbc4e2d266964792afd
8 changes: 8 additions & 0 deletions best_practices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ application behavior.
:ref:`Use env vars in your project <config-env-vars>` to define these options
and create multiple ``.env`` files to :ref:`configure env vars per environment <config-dot-env>`.

Use Secret for Sensitive Information
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These are the options used to store sensitive information like passwords,
tokens, api key

:ref:`Use secrets <secrets-set>` to define these options in an easy and secure way.

Use Parameters for Application Configuration
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
53 changes: 53 additions & 0 deletions configuration/env_var_processors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,59 @@ Symfony provides the following env var processors:

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

``env(secret:FOO)``
Reads a secret value stored in the app's vault, :ref:`see how to set Secrets<secrets-set>`.

.. code-block:: terminal

$ php bin/console secrets:set DATABASE_PASSWORD -

.. configuration-block::

.. code-block:: yaml

# config/packages/database.yaml
doctrine:
dbal:
# by convention the env var names are always uppercase
url: '%env(DATABASE_URL)%'
password: '%env(secret:DATABASE_PASSWORD)%'

.. code-block:: xml

<!-- config/packages/doctrine.xml -->
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:doctrine="http://symfony.com/schema/dic/doctrine"
xsi:schemaLocation="http://symfony.com/schema/dic/services
https://symfony.com/schema/dic/services/services-1.0.xsd
http://symfony.com/schema/dic/doctrine
https://symfony.com/schema/dic/doctrine/doctrine-1.0.xsd">

<doctrine:config>
<!-- by convention the env var names are always uppercase -->
<doctrine:dbal url="%env(DATABASE_URL)%" password="%env(secret:DATABASE_PASSWORD)%"/>
</doctrine:config>

</container>

.. code-block:: php

// config/packages/doctrine.php
$container->loadFromExtension('doctrine', [
'dbal' => [
// by convention the env var names are always uppercase
'url' => '%env(DATABASE_URL)%',
'password' => '%env(secret:DATABASE_PASSWORD)%',
]
]);


.. versionadded:: 4.4

The ``secret`` processor was introduced in Symfony 4.4.

It is also possible to combine any number of processors:

.. code-block:: yaml
Expand Down
Loading