Skip to content

[Secrets] Add a section to give the best pratices for accessing secrets in a service#21865

Open
tcoch wants to merge 1 commit intosymfony:6.4from
tcoch:using-secrets-in-a-service
Open

[Secrets] Add a section to give the best pratices for accessing secrets in a service#21865
tcoch wants to merge 1 commit intosymfony:6.4from
tcoch:using-secrets-in-a-service

Conversation

@tcoch
Copy link
Copy Markdown
Contributor

@tcoch tcoch commented Feb 5, 2026

Last week I was wondering what was the best way of handling this subject, and couldn't find the answer (though I found multiple ways of doing it with different technical approches).
I propose this PR to document this way of accessing secrets values inside a service, as the 'best pratice' if this is in fact agreed upon.

@carsonbot carsonbot added this to the 6.4 milestone Feb 5, 2026
@lacatoire
Copy link
Copy Markdown
Contributor

lacatoire commented Apr 1, 2026

Hi @tcoch, thanks for your PR.
Since secrets are just regular environment variables, this is already covered by the autowiring docs. A full section would be redundant, but a seealso would help discoverability. Could you replace your changes with this instead?

  .. seealso::

      Since secrets are exposed as environment variables, you can inject them
      into services using the ``#[Autowire]`` attribute
      (e.g. ``#[Autowire(env: 'MY_SECRET')]``). See :doc:`/service_container/autowiring`
      for details.

Right after the .env.test code block (line 220), before the "Deploy Secrets to Production" section.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants