[DependencyInjection] Allow injecting the current env into php config closures #47906
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The original idea of this PR was to allow injecting
string $env
into php config closures. Even though this can be done by injectingContainerConfigurator
& callingenv()
it seems kind of redundant when you don't need any features except the current env, eg when using the config builder classes:Injecting the
$env
variable looks a bit cleaner IMO.However, while working on this PR I discovered #41182 . Even though there's already an
$env
variable presets in the scope of php files which can be used for the same thing, it's not really IDE friendly:Since the original PR mentioned the that the
$env
variable was added for PHP <8 & Symfony 6.2 is >=8.1, it doesn't seem to be needed any more, so it can be deprecated.