Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Merged
fabpot merged 1 commit intosymfony:masterfromnicolas-grekas:di-compile-env
Feb 9, 2017

Conversation

@nicolas-grekas
Copy link
Member

@nicolas-grekasnicolas-grekas commentedJan 30, 2017
edited
Loading

QA
Branch?master
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?yes
Tests pass?yes
Fixed tickets#21420
LicenseMIT
Doc PR-

Here is a new feature allowing one to do$container->compile(true) and get the env vars resolved using the current env.

@chalasr
Copy link
Member

chalasr commentedJan 30, 2017
edited
Loading

👍

* * Extension loading is disabled.
*/
publicfunctioncompile()
publicfunctioncompile(/* $resolveEnvPlaceholders = false */)
Copy link
Contributor

@olvlvlolvlvlJan 30, 2017
edited
Loading

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?

Copy link
MemberAuthor

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)%');

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?

Copy link
MemberAuthor

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

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

tests added

javiereguiluz reacted with thumbs up emoji
@fabpot
Copy link
Member

Can you add some docs in the phpdocs?

olvlvl and wersoo reacted with thumbs up emoji

@nicolas-grekas
Copy link
MemberAuthor

phpdoc added

* * 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
Copy link
Member

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.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

comment updated

@nicolas-grekasnicolas-grekasforce-pushed thedi-compile-env branch 3 times, most recently froma735b0e to6ea3a24CompareFebruary 3, 2017 12:26
@fabpot
Copy link
Member

Thank you@nicolas-grekas.

@fabpotfabpot merged commita3fd512 intosymfony:masterFeb 9, 2017
fabpot added a commit that referenced this pull requestFeb 9, 2017
…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
@nicolas-grekasnicolas-grekas deleted the di-compile-env branchFebruary 14, 2017 16:21
@fabpotfabpot mentioned this pull requestMay 1, 2017
@zippy1981
Copy link

I tried to capture how to do thisin a stackoverflow answer.

@pwm
Copy link

pwm commentedJun 15, 2017

@zippy1981 Thanks for that SO answer, however I can't seem to get it working. If I replace$container->compile(); with$container->compile(true); in theinitializeContainer() method ofSymfony\Component\HttpKernel\Kernel then everything works fine, however if I add$container->compile(true); to my own bundle then nothing happens. Where exactly should I add this line?

@stof
Copy link
Member

@pwm why would you want to use this argument in your bundle ?

@pwm
Copy link

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 anIncompatible use of dynamic environment variables... error. If I understand it correctly this PR is resolving this issue.

pchel reacted with thumbs up emoji

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

Reviewers

@fabpotfabpotfabpot left review comments

@javiereguiluzjaviereguiluzjaviereguiluz left review comments

+1 more reviewer

@olvlvlolvlvlolvlvl left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

9 participants

@nicolas-grekas@chalasr@fabpot@zippy1981@pwm@stof@javiereguiluz@olvlvl@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp