Skip to content

Commit 19e4c7c

Browse files
committed
Merge branch '7.2' into 7.3
* 7.2: Minor reword Document how to resolve env var at compile time
2 parents 93ccd45 + 6a164b6 commit 19e4c7c

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

components/dependency_injection/compilation.rst

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,3 +608,25 @@ have the cache will be considered stale.
608608

609609
In the full-stack framework the compilation and caching of the container
610610
is taken care of for you.
611+
612+
.. _resolving-env-vars-at-compile-time:
613+
614+
Resolving Environment Variable At Compile Time
615+
----------------------------------------------
616+
617+
.. caution::
618+
619+
**This practice is discouraged**. Use it only if you fully understand the implications.
620+
621+
By default, environment variables are resolved at runtime. However, you can
622+
force their resolution at compile time using the following code::
623+
624+
$parameterValue = $container->resolveEnvPlaceholders(
625+
$container->getParameter('%env(ENV_VAR_NAME)%'),
626+
true // resolve to actual values
627+
);
628+
629+
However, a **major drawback** of this approach is that you must manually clear
630+
the cache when changing the value of an environment variable. This goes
631+
against the typical behavior of environment variables, which are designed
632+
to be dynamic and not require cache invalidation.

configuration/env_var_processors.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -951,3 +951,9 @@ To enable the new processor in the app, register it as a service and
951951
tag. If you're using the
952952
:ref:`default services.yaml configuration <service-container-services-load-example>`,
953953
this is already done for you, thanks to :ref:`autoconfiguration <services-autoconfigure>`.
954+
955+
Resolving Environment Variable At Compile Time
956+
----------------------------------------------
957+
958+
Environment variables are resolved at runtime, but you can also resolve them
959+
:ref:`at compile time <resolving-env-vars-at-compile-time>`.

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