-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DependencyInjection] Make Container::getEnv
public
#46819
Conversation
@malarzm Could it help for the following topics? Currently it seems complicated to resolve environment variable on loading extensions. |
No, this PR barely exposes accessing env variables to the outside world and does not change any parameters vs envs vs extensions. |
@raziel057 not reading environment variables inside extensions is not a bug. It is a feature. 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. |
@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 |
@raziel057 for such case, I'm still using https://github.com/Incenteev/ParameterHandler to create non-env-based parameters during |
I'm 👎 for the reasons given by @stof. Closing therefore, thanks for suggesting. |
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. |
would this already be achievable using either the |
It wouldn't expose processors that way as its logic is defined by |
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
public
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 |
Closing as explained, thanks for proposing. |
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
getEnv
public we're exposing not only raw values one could get withgetenv
but 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 :)