-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Environment Variable Processors not working #37426
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
There is a major difference between what you did previously in It is not possible to use I don't know why the error message tells that a string was passed (/cc @ro0NL maybe if you want to have a look). But this is not the issue you're reporting so I'm still closing. Thanks for your understanding. |
(Note that the error message should be fixed by #37511) |
I reread the documentation. Yes, this is my mistake. Sorry. I thought that environment variables are compiled once into a container as usual parameters, but it turned out that they are parsed for each request. It turns out that when i do not need to recognize environment variables in runtime i have to use the old approach like this: # parameters.php
$container->setParameter('web_profiler', (bool) getenv('WEB_PROFILER')); # web_profiler.yml
web_profiler:
toolbar: '%web_profiler%'
intercept_redirects: false
framework:
profiler:
enabled: '%web_profiler%'
collect: '%web_profiler%'
only_exceptions: false It would be nice to separate environment variables into those that should be used in runtime and those that can be compiled. |
…ue prefixes for dynamic placeholder values (fancyweb) This PR was merged into the 4.4 branch. Discussion ---------- [DependencyInjection][Config] Use several placeholder unique prefixes for dynamic placeholder values | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #37426 | License | MIT | Doc PR |- Currently, in Config BaseNode, we are only able to check on one dynamic placeholder unique prefix (ie one env placeholder unique prefix in our usage) to ignore the validation of config values that contain placeholder values. It isn't enough in some scenarios, we would need to be able to check on multiple prefixes. In MergeExtensionConfigurationPass we need to not validate config values that are placeholders (they are checked later by a dedicated pass), so we set the BaseNode placeholder unique prefix for each processed extension. Because the env placeholder unique prefix depends of the bag data, if a first extension creates the env placeholder and adds a parameter to the bag, the second extension reusing the same env placeholder will generate a different env placeholder unique prefix. Therefore the validation of the value will not be skipped because the env placeholder contains the first env placeholder unique prefix while the BaseNode placeholder unique prefix is set with the second. Another solution might be to mutate the existing env placeholders to use the new unique prefix when merging the env placeholders ? I guess it depends on which side we want to fix this (DI or Config). cc @ro0NL Commits ------- 3d754ad [DependencyInjection][Config] Use several placeholder unique prefixes for dynamic placeholder values
Symfony version(s) affected: 4.4.10
Description
The documentation says that i can use type conversion for environment variables in configuration files, but this does not work for me.
I am trying to upgrade a project from Symfony 3.4 to 4.4. Maybe i missed something.
Previously, i used an explicit conversion in the PHP file
parameters.php
.How to reproduce
Reproducing Complex Bugs
https://github.com/peter-gribanov/symfony_issue_37426
My config
throw error
Possible Solution
Additional context
The text was updated successfully, but these errors were encountered: