Skip to content

Typed env var and allow nullable #28618

@steevanb

Description

@steevanb

Description
For now, DotEnv component don't allow null as value and don't type values.
We can type value when reading, with %env(int:foo)%. But if an env var is used more than one time, we have to duplicate type hint at each read.

Can we take that problem (typing at reading) on the other side: typing at declaration, not at reading ?

For null value, it's impossible for now, and that's a problem. Maybe we can have a syntax to allow null at declaration ?

Example
/.env
VAR_INT=!int:12
VAR_FLOAT=!float:12.2
VAR_STRING=!string:foo
VAR_STRING_2=foo
VAR_ALLOW_NULL=!?string:null
VAR_ARRAY=!array:[!int:12, !string:foo]

Problems

As DotEnv is installed for dev env by default, how can we do to parse env var in prod env ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    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