Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy