Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DI] ContainerBuilder::compile() can optionally resolve env vars in parameter bag#21460
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
chalasr commentedJan 30, 2017 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
👍 |
| * * Extension loading is disabled. | ||
| */ | ||
| publicfunctioncompile() | ||
| publicfunctioncompile(/* $resolveEnvPlaceholders = false */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
How about using a flag (e.g.self::RESOLVE_ENV_PLACEHOLDERS) instead of a boolean, so that additional features may be introduced without requiring additional parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
IMHO, we shouldn't plan for additional unplanned features :) This can be changed easily in the futureif needed.
| $_ENV['DUMMY_ENV_VAR'] ='du%%y'; | ||
| $container =newContainerBuilder(); | ||
| $container->setParameter('bar','%% %env(DUMMY_ENV_VAR)%'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
What will happen in the other two cases: 1) undefined env var; 2) undefined env var, but default value defined for it. Should we add those cases to this test too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
same as usual, this is exactly the same code/logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
tests added
8b278b2 to13ea687Comparefabpot commentedJan 30, 2017
Can you add some docs in the phpdocs? |
13ea687 toff4c1f0Comparenicolas-grekas commentedJan 30, 2017
phpdoc added |
ff4c1f0 to1a2b1cbCompare| * * Extension loading is disabled. | ||
| * | ||
| * @param bool $resolveEnvPlaceholders Whether %env()% parameters should be resolved using the current | ||
| * env vars or be replaced by uniquely identifiable placeholders |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
That describes what it does, but I'd like to understand alsowhen I should passtrue here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
comment updated
a735b0e to6ea3a24Compare6ea3a24 toa3fd512Comparefabpot commentedFeb 9, 2017
Thank you@nicolas-grekas. |
…e env vars in parameter bag (nicolas-grekas)This PR was merged into the 3.3-dev branch.Discussion----------[DI] ContainerBuilder::compile() can optionally resolve env vars in parameter bag| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | yes| BC breaks? | no| Deprecations? | yes| Tests pass? | yes| Fixed tickets |#21420| License | MIT| Doc PR | -Here is a new feature allowing one to do `$container->compile(true)` and get the env vars resolved using the current env.Commits-------a3fd512 [DI] ContainerBuilder::compile() can optionally resolve env vars in parameter bag
zippy1981 commentedMay 18, 2017
I tried to capture how to do thisin a stackoverflow answer. |
pwm commentedJun 15, 2017
@zippy1981 Thanks for that SO answer, however I can't seem to get it working. If I replace |
stof commentedJun 15, 2017
@pwm why would you want to use this argument in your bundle ? |
pwm commentedJun 16, 2017
@stof I'm trying to get env vars work as monolog config values, pretty much exactly like the SO entry above, but I get an |
Uh oh!
There was an error while loading.Please reload this page.
Here is a new feature allowing one to do
$container->compile(true)and get the env vars resolved using the current env.