Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DI] Allow reseting of env vars loaded by EnvVarLoaderInterface implementations #54627

Closed
@faizanakram99

Description

@faizanakram99

Description

Services tagged with container.env_var_loader are loaded by EnvVarProcessor to load env vars dynamically. Right now there is no way to reset such env vars once they're loaded mainly because they're cached in memory once loaded . This seems by design to improve performance, however, it limits the usage of EnvVarLoader in messenger context say with a multi-tenant app where a single worker can handle messages from various tenants.

This slack thread might give a bit more context https://symfony-devs.slack.com/archives/C8WHX21K7/p1713264333709759

Possible solution:
EnvVarProcessor can possibly implement reset interface and allow reseting some env vars (maybe via a config option?), especially the ones which are loaded by EnvVarLoaderInterface implementations, since the env vars loaded by EnvVarLoaderInterface aren't actual env vars and are dynamic (or runtime) by definition to begin with, it makes sense to allow resetting them.

This would allow using symfony messenger easily in a multi-tenant app where env vars are loaded based on tenant id.

Example

No response

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