Skip to content

Typed env var and allow nullable #28618

Closed
@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