Skip to content

Conversation

@carlos-ea
Copy link
Contributor

When using environment variables as values for config parameters that are read conditionally, symfony can mark that environment variable as unused and throw a fatal error.

For example, the following config:

translation:
    fallback_translation:
        enabled: '%env(bool:FALLBACK_TRANSLATION_ENABLED)%'

Will result in a fatal error if the environment variable is not used elsewhere. Environment variables "bool:FALLBACK_TRANSLATION_ENABLED" are never used. Please, check your container's configuration.

This PR solves this issue, see symfony/symfony#23520 (comment) and the comment below that.

@odolbeau
Copy link
Member

odolbeau commented Jan 8, 2020

Thanks!
That's the first time I heard about that! :D

@Nyholm
Copy link
Member

Nyholm commented Jan 11, 2020

Thank you

@Nyholm Nyholm merged commit aa65cf3 into php-translation:master Jan 11, 2020
bastnic added a commit to bastnic/flysystem-bundle that referenced this pull request Feb 24, 2020
When using environment variables as values for config parameters that are read conditionally, symfony can mark that environment variable as unused and throw a fatal error.

See php-translation/symfony-bundle#379 and symfony/symfony#23520 (comment)
@nicolas-grekas
Copy link

This change is wrong: it defeats the purpose of env vars.

@odolbeau
Copy link
Member

@nicolas-grekas Thanks for let us know.
Sorry if the question sounds silly but what are we supposed to do in a bundle to let end users use environment variables in config?

@nicolas-grekas
Copy link

There are places where using env vars doesn't make sense, is not possible, or needs to be supported by runtime factories.

Enabling/disabling features should usually be controlled by per-symfony-env parameters (in the example here e.g.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants