10000 Feature Request: Enhance Env var processing with recursive env var resolution · Issue #28078 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Feature Request: Enhance Env var processing with recursive env var resolution #28078
Closed
@bendavies

Description

@bendavies

Description
As an enhancement to #23901, It would be nice to support recursive env var resolution. It is not obvious from the docs or PR (unless i'm missing something), that this is not already supported, so I went around in circles trying to make it work for a while, until Nicolas helped me.

cc @nicolas-grekas

Example
Given environment variables:

DATABASE_URL=postgres://user:%env(DATABASE_PASSWORD)%@127.0.0.1:5432/database
DATABASE_PASSWORD=foo

And some configuration:

parameters:
    env(DATABASE_PASSWORD): ''
    env(DATABASE_URL): ''

doctrine:
...
   url: '%env(resolve:DATABASE_URL)%'

DATABASE_PASSWORD in DATABASE_URL should be resolved, but it is not.

Current Workaround
You must instead use an intermediary parameter:

DATABASE_URL=postgres://user:%database_password%@127.0.0.1:5432/database
DATABASE_PASSWORD=foo
parameters:
    database_password: '%env(DATABASE_PASSWORD)'
    env(DATABASE_PASSWORD): ''
    env(DATABASE_URL): ''

doctrine:
...
   url: '%env(resolve:DATABASE_URL)%'

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

      0