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

Skip to content

Allow to set disable_dotenv via environment variable #60755

Open
@danrot

Description

@danrot

Description

I have a Symfony application in which I want to load all the .env files for local development, but not in the production environment, in which I handle those differently by using some tools offered by the cloud provider. So what I've ended up with is adding the following lines in public/index.php and in bin/console:

$_SERVER['APP_RUNTIME_OPTIONS'] = [
	'disable_dotenv' => ($_SERVER['APP_ENV'] ?? null) === 'prod',
];

I find this quite cumbersome and it leads to duplicated code. Therefore I would suggest to introduce an environment variable, which is handled somehow by Symfony (e.g. the Runtime component). Then I could just set this variable in our cloud environment. I would also be open to contribute this myself after receiving at least some guidance.

Example

I would suggest that instead of the above code I can set an environment variable to disable loading .env files. E.g. something like this:

APP_DISABLE_DOTENV=1

With that variable being set to 1 .env files would not be loaded, if it is set to 0 they are being loaded.

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