From 4aaca90daf15d09361711a7cf053e35de9524960 Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Sun, 20 Jul 2025 17:37:11 +0200 Subject: [PATCH] Document how to resolve env var at compile time --- .../dependency_injection/compilation.rst | 18 ++++++++++++++++++ configuration/env_var_processors.rst | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/components/dependency_injection/compilation.rst b/components/dependency_injection/compilation.rst index 06233a6baed..9a48003de38 100644 --- a/components/dependency_injection/compilation.rst +++ b/components/dependency_injection/compilation.rst @@ -612,3 +612,21 @@ have the cache will be considered stale. In the full-stack framework the compilation and caching of the container is taken care of for you. + +.. _resolving-env-vars-at-compile-time: + +Resolving Environment Variable At Compile Time +---------------------------------------------- + +Environment variables value can be resolved at compile time by using the following code:: + + $parameterValue = $container->resolveEnvPlaceholders( + $container->getParameter('%env(ENV_VAR_NAME)%'), + true // Resolve to actual values + ); + +.. warning:: + + Environment variables are usually a runtime concern. One of the major drawbacks of resolving them + at compile time is that you'll need to manually clear the cache when changing their value (which is exactly + what you don't have to do for env vars under normal circumstances). diff --git a/configuration/env_var_processors.rst b/configuration/env_var_processors.rst index 1e57fd65387..fbd7d38754b 100644 --- a/configuration/env_var_processors.rst +++ b/configuration/env_var_processors.rst @@ -912,3 +912,9 @@ To enable the new processor in the app, register it as a service and tag. If you're using the :ref:`default services.yaml configuration `, this is already done for you, thanks to :ref:`autoconfiguration `. + +Resolving Environment Variable At Compile Time +---------------------------------------------- + +Although environment variables are usually a runtime concept, you can also resolve them +:ref:`at compile time `. 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