-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI], [Config] - Environment variables can not be used with configuration nodes of concrete types #25868
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 add more details: floatNode will receive for validation the placeholder of parameter created in https://github.com/symfony/dependency-injection/blob/master/ParameterBag/EnvPlaceholderParameterBag.php#L51 but not the value. Evident that placeholder is string, but not float, int or whatever we expect. A little bit more detailed description: 8p/EightPointsGuzzleBundle#184 (comment) |
Fix in progress in #23888? |
This is actually a critical issue blocking replacement of parameters with environment variables for us, as well as I'm guessing many others (working to use Docker right now). Hopefully the fix isn't stuck for too long as the last comment suggested. |
Kind of critical for us too, since some third-party bundles require types, e.g. integers for port numbers: Of course we could fork the bundle and adapt, but would be great to have this working out-of-the-box. |
Anyone willing to try an updated version of #23888 :) I think it's working. |
This PR was squashed before being merged into the 4.1-dev branch (closes #23888). Discussion ---------- [DI] Validate env vars in config | Q | A | ------------- | --- | Branch? | 4.1/master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22151, #25868 | License | MIT | Doc PR | symfony/symfony-docs#8382 This PR registers the env placeholders in `Config\BaseNode` with its default value or an empty string. It doesnt request real env vars during compilation, What it does is if a config value exactly matches a env placeholder, we validate/normalize the default value/empty string but we keep returning the env placeholder as usual. If a placeholder occurs in the middle of a string it also proceeds as usual. The latter to me is OK as you need to expect any string value during runtime anyway, including the empty string. Commits ------- 2c74fbc [DI] Validate env vars in config
Suppose we have defined such configuration in
Configuration.php
:Next we want to use environment variable for this configuration, as described here:
After that we add
MY_VALUE
into.env
file and try to runThe execution result will be an error:
The command should be executed successfully.
Repository with code to reproduce this situation. The steps:
The text was updated successfully, but these errors were encountered: