Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] MakeContainer::getEnv public#46819
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
raziel057 commentedJun 30, 2022
@malarzm Could it help for the following topics? Currently it seems complicated to resolve environment variable on loading extensions. |
malarzm commentedJun 30, 2022
No, this PR barely exposes accessing env variables to the outside world and does not change any parameters vs envs vs extensions. |
stof commentedJun 30, 2022
@raziel057 not reading environment variables inside extensions is not a bug. It is afeature. The whole promise of env placeholders in the DependencyInjection is that new values of the environment variable will be taken into account without requiring to clear the cache. So if a container extension uses a setting to change the structure of the container instead of injecting into a service, it cannot use an env placeholder. |
raziel057 commentedJun 30, 2022
@stof Thanks for your answer. The issue is that often when you deploy an app in a container for example you don't want to embed a config file for static parameters that can change if you deploy the same image in different environment. It would be just nice / easier to be able to specify if the ENV should be resolved statically or not. I have seen lots of people simply define static ENV vars in docker compose files or Kubernetes Management Platforms like Rancher for example. I just seen this have been already discussed here:#40794 |
stof commentedJul 1, 2022
@raziel057 for such case, I'm still usinghttps://github.com/Incenteev/ParameterHandler to create non-env-based parameters during |
nicolas-grekas commentedJul 9, 2022
I'm 👎 for the reasons given by@stof. Closing therefore, thanks for suggesting. |
malarzm commentedJul 9, 2022
I'm sorry but I'm missing the reasons? To me it looks like discussion was unrelated to the proposal itself as it was about how envs are behaving. |
ro0NL commentedJul 11, 2022
would this already be achievable using either the |
malarzm commentedJul 11, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
It wouldn't expose processors that way as its logic is defined by |
ro0NL commentedJul 11, 2022
IMHO the way forward would be which currently only works using a hack like parameters:env(csv:APP_FOO):'%env(csv:APP_FOO)%' making it work out-of-the-box would be more elegant though. |
Container::getEnv publicnicolas-grekas commentedJul 29, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Rereading this again I'm 👎 here: exposing new APIs is increasing the maintenance cost, and here, ppl will jump into using the method and shooting themself in the foot (see comments from@raziel057 and@stof)
Yes, that's a good way forward (it works with any parameter name, not only |
nicolas-grekas commentedAug 2, 2022
Closing as explained, thanks for proposing. |
Uh oh!
There was an error while loading.Please reload this page.
In our app we're controlling certain features' availability with feature switches defined in envs (to prevent non-tech folks from turning them on without our assitance). We'd like to show whether those switches are on or off in the administration panel. Sadly, there is no kosher way to get those values during runtime other than injecting every variable we want to show. By making
getEnvpublic we're exposing not only raw values one could get withgetenvbut more importantly processors. By the way we're also ironing out two not-so-great hacks to get env variables in Symfony itself (included in PR).Code will need finishing if we agree this is good idea:
I just don't want to waste time on these in case the PR will be shot down :)