8000 [DependencyInjection] Can't bind environment variable · Issue #24845 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DependencyInjection] Can't bind environment variable #24845

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mykiwi opened this issue Nov 6, 2017 · 3 comments
Closed

[DependencyInjection] Can't bind environment variable #24845

mykiwi opened this issue Nov 6, 2017 · 3 comments

Comments

@mykiwi
Copy link
Contributor
mykiwi commented Nov 6, 2017
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.4

We can't bind env variables.

Example:

services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false
        bind:
            $foo: '%env(BAR)%'

Generate (in var/cache/ContainerXXXXX/getFooService.php):

...
return $this->services['App\Foo'] = new \App\Foo($this->getParameter('env(BAR)'));

But it should be $this->getEnv('BAR')


Work around:

parameters:
    BAR: '%env(BAR)%'

services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false
        bind:
            $foo: '%BAR%'
@sroze
Copy link
Contributor
sroze commented Nov 6, 2017

I think that it is expected, as AFAIK the %env(...)% magic only works with parameters 🤔

@nicolas-grekas
Copy link
Member

@sroze: both ways of writing config should end up with the same (almost) container. Here, it's not, so there is definitely a bug.

@ogizanagi
Copy link
Contributor

#24850 should fix this issue

nicolas-grekas added a commit that referenced this issue Nov 7, 2017
This PR was merged into the 3.4 branch.

Discussion
----------

[DI] Fix cannot bind env var

| Q             | A
| ------------- | ---
| Branch?       | 3.4 <!-- see comment below -->
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #24845 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

In #24602 we removed the processing of bindings from the `AbstractRecursivePass`. But there is actually one case where we want a recursive pass to process them: to resolve env param placeholders.

Commits
-------

f8f3a15 [DI] Fix cannot bind env var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
P 3E7D rojects
None yet
Development

No branches or pull requests

6 participants
0