Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[WIP][DependencyInjection] Issue #7555 - Resolve environment variables at runtime#10138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
lavoiesl commentedJan 25, 2014
So far, the issues in the build do not seem to be linked to this PR. |
mvrhov commentedJan 26, 2014
Can I suggest an improvement.. This run-time resolver could also resolve the parameters set via the newly introduced expression engine. |
lavoiesl commentedJan 26, 2014
This could indeed be considered, but this would be a separate PR isn’t it ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Property names should use camel case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks
fabpot commentedNov 12, 2015
Closing as it does not fix the problem in all cases (see the referenced other PR I created which also failed). |
…env(MY_ENV_VAR)% (nicolas-grekas)This PR was merged into the 3.2-dev branch.Discussion----------[DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)%| Q | A| ------------- | ---| Branch? | master| New feature? | yes| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#10138,#7555,#16403,#18155| License | MIT| Doc PR |symfony/symfony-docs#6918This is an alternative approach to#18155 for injecting env vars into container configurations.With this PR, anywhere parameters are allowed, one can use `%env(ENV_VAR)%` to inject a dynamic env var. Additionally, if one sets a value to such parameters in e.g. the `parameter.yml` file (`env(ENV_VAR): foo`), this value will be used as a default value when the env var is not defined. If no default value is specified, an `EnvVarNotFoundException` will be thrown at runtime.Unlike previous attempts that also used parameters (#16403), the implementation is compatible with DI extensions: before being dumped, env vars are resolved to uniquely identifiable string placeholders that can get through DI extensions manipulations. When dumped, these unique placeholders are replaced by dynamic calls to a getEnv method..ping@magnusnordlander@dzuelke@fabpotCommits-------bac2132 [DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)% syntax
This allows to set a parameter
environment_mapthat contains a map[$parameter => $env_var]. This allows to callParameterBag::resolveEnvironmentMapeven after the bag was initially resolved and frozen. As mentioned by@stof, dependent parameter can not be resolved anymore, so it is forbidden to reference a parameter in the environment map elsewhere. However,resolveEnvironmentMapwill useresolveValue, so it is possible to reference another parameter in the enviromnent variable.HttpKernelnow callsParameterBag::resolveEnvironmentMapafter theContainerwas fully loaded.I am not entirely sure of the implication of this method with the caching mechanism, the cache warmers, etc. I could use some help from someone with a better understanding of the whole thing.
The only BC break is that
environment_mapis not a valid parameter name anymore, it is reserved.