Skip to content

[DI][Improvement] Allow to define a default value on environment variables #25129

Closed
@vincentchalamon

Description

@vincentchalamon
Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Symfony version 3.4

Since Symfony 3.4, it's now possible to parse environment variables using %env()% tool: https://goo.gl/8Zsed6

But in some environment, I don't have the right environment variables set, so the application is not bootable (on Insight analysis for instance). To fix it, I need to define the environment variable on a parameter key:

parameters:
    db_hostname: '%env(DB_HOSTNAME)%'
    env(DB_HOSTNAME): db

doctrine:
    dbal:
        host: '%db_hostname%'

It should be interesting to parse a default value directly on the %env()% tool:

doctrine:
    dbal:
        host: '%env(default:db:DB_HOSTNAME)%'

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