Skip to content

[DependencyInjection] Can't bind environment variable #24845

Closed
@mykiwi

Description

@mykiwi
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%'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions