Skip to content

kernel.environmentconfig: mistmatch between documentation and implementation #215

@tucksaun

Description

@tucksaun

The current documentation states:

It allows you to force using a given environment. If it is not set, it uses APP_ENV environment variable if defined or falls back to test.

However, the current code does not implement this:

private function setupTestEnvironment(string $fallback): void
{
// If there's no defined server / environment variable with an environment, default to configured fallback
if (($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) === null) {
putenv('APP_ENV=' . $_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = $fallback);
}
}

The actual behavior of the code is to setup only if APP_ENV is not already defined (so not to force it) and the configuration value fallbacks to test (see

$this->setupTestEnvironment($config['kernel']['environment'] ?? 'test');
).

I'm willing to submit a PR to fix this issue but wanted to know which way the maintainers want to move: fix the documentation that is misleading or fix the behavior in order to match the documentation?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions