This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php
Fabien Potencier 1bcade56e6 feature #19681 [DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)% (nicolas-grekas)
This PR was merged into the 3.2-dev branch.

Discussion
----------

[DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)%

| Q             | A
| ------------- | ---
| Branch?       | master
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |  #10138, #7555, #16403, #18155
| License       | MIT
| Doc PR        | https://github.com/symfony/symfony-docs/pull/6918

This is an alternative approach to #18155 for injecting env vars into container configurations.

With this PR, anywhere parameters are allowed, one can use `%env(ENV_VAR)%` to inject a dynamic env var. Additionally, if one sets a value to such parameters in e.g. the `parameter.yml` file (`env(ENV_VAR): foo`), this value will be used as a default value when the env var is not defined. If no default value is specified, an `EnvVarNotFoundException` will be thrown at runtime.

Unlike previous attempts that also used parameters (#16403), the implementation is compatible with DI extensions: before being dumped, env vars are resolved to uniquely identifiable string placeholders that can get through DI extensions manipulations. When dumped, these unique placeholders are replaced by dynamic calls to a getEnv method..

ping @magnusnordlander @dzuelke @fabpot

Commits
-------

bac2132 [DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)% syntax
2016-09-15 10:44:52 -07:00
..
services1-1.php [DI] Remove deprecated scope concept 2015-09-04 22:04:06 +02:00
services1.php [DI] Remove deprecated scope concept 2015-09-04 22:04:06 +02:00
services8.php [DI] Remove deprecated scope concept 2015-09-04 22:04:06 +02:00
services9_compiled.php [DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)% syntax 2016-09-10 12:12:34 +02:00
services9.php [DI] Dont use Container::get() when fetching private services internally 2016-08-26 17:24:58 +02:00
services10.php [DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)% syntax 2016-09-10 12:12:34 +02:00
services12.php [DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)% syntax 2016-09-10 12:12:34 +02:00
services13.php Merge branch '2.8' into 3.1 2016-08-23 15:39:15 +02:00
services19.php Merge branch '2.8' into 3.0 2016-06-29 07:40:00 +02:00
services24.php Merge branch '2.8' into 3.0 2016-06-29 07:40:00 +02:00
services26.php [DI] Allow injecting ENV parameters at runtime using %env(MY_ENV_VAR)% syntax 2016-09-10 12:12:34 +02:00
simple.php moved component and bridge unit tests to the src/ directory 2012-03-29 08:37:22 +02:00