-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Symfony Config Component does not recognize environment variables #28599
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
Comments
To be honest, I expect this example to work. The other issues gave some explanations about this expected behaviour ... but I'm not convinced 😕 |
By design :)
To support this, we need that info. So with a notation like |
Yes, but it's the "by design" thing which I don't understand. Right now it works like this:
I'd like to work it like this:
Does it make sense ... or would it be a worse behaviour? |
We can allow it sure, but it defeats config validation. You can already allow it by using variable node. For core i'd to look at @nicolas-grekas suggestion (#28137 (comment)) to basically allow the array (change core to variable node) and validate the elements to be scalar during runtime. That's a per case change anyway, from config pov i'm still happy with the current design. But as mentioned, the more type info we can extract from the env prefix, the better we can make the integration with config validation. |
Also. to make this valid for now, the same logic applies as #28137 (comment)
|
I'm afraid I don't follow you. What's the difference between |
any but not any |
That's where we disagree. If Symfony doesn't know for sure if something is right or wrong, it should abstain. |
Then it should abstain from validating during compile time. At least it should not allow for false positives. If the node is configured to requires type A, but gets type B it should crash. Period. So if want to use an arbitrary array from JSON in config, then config should also allow for a variable (protyped) array. |
As soon as the Config component performs some normalization of the input (which is the case here to accept passing a string rather than an array when you need a single value), this does not play well with env placeholders, as the normalization logic runs on the placeholder itself, not on the value (as it is not known).
The assumption for bundles is that once a semantic config is validated using the Config component, they can use it safely to configure their code. If you suggest Symfony to accept values, then this assumption gets broken. Symfony cannot abstain. Either it accepts the value when processing the config, or it rejects it. Side note: We already deprecated the config for |
Hi guys, Please help me understand how can "by design" go from allowing the use of arrays in configs to not allowing the use of arrays using environment variable. The solution proposed is to add an environment variable for each array and then add a new array item in the config as such : I believe this solution is not scalable and removes the option of dynamism. What if I want 2 emails on my dev environment, but I want 3 on my production environment. Of vice versa. I would like a replacement that will allow the use of a scalable structure such as the following : What is the solution proposed? |
Hi guys, I've managed to make the code work manually overwriting :
No errors were thrown. The goal would be to find a way to overwrite them without directly editing the Vendors. |
See #29270 for a different approach :) |
Closing in favor of #29270 |
Symfony version(s) affected: 4.1
Description
Following the documentation on a fresh installed Symfony 4.1.
https://symfony.com/doc/current/configuration/external_parameters.html#environment-variable-processors
Copying and pasting these configuration in

config/packages/framework.yaml
Getting an exception:
My environment does not contain a
TRUSTED_PROXIES
variable.It looks like a bug with a JSON environment variables passed to configuration. If it's by design than it's a documentation bug.
Maybe related to #28137 and #23888
The text was updated successfully, but these errors were encountered: