Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dotenv] [DumpCommand] Incorrectly detected envKey if it differs from APP_ENV #53864

Closed
scruwi opened this issue Feb 8, 2024 · 0 comments
Closed

Comments

@scruwi
Copy link
Contributor

scruwi commented Feb 8, 2024

Symfony version(s) affected

6.4

Description

If env_var_name in composer.json differs from the standard APP_ENV, then .env.PRODUCTION file will be ignored by the command bin/console dotenv:dump PRODUCTION

How to reproduce

composer.json:

"extra": {
    "runtime": {
        "env_var_name": "ENV"
    }
}

Create files:

  • .env
  • .env.local
  • .env.local.PRODUCTION

Run bin/console dotenv:dump PRODUCTION

Possible Solution

Method DotenvDumpCommand::loadEnv(), instantiate DotEnv with correct envKey:

$envKey = $config['env_var_name'] ?? 'APP_ENV';
$dotenv = new Dotenv($envKey);

Additional Context

No response

@scruwi scruwi added the Bug label Feb 8, 2024
nicolas-grekas added a commit that referenced this issue Feb 9, 2024
…otenv:dump (scruwi)

This PR was merged into the 6.4 branch.

Discussion
----------

[Dotenv] Specify envKey while loading variables with the dotenv:dump

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #53864
| License       | MIT

`bin/console dotenv:dump` incorrectly detected envKey if it differs from APP_ENV

Commits
-------

f188a24 [Dotenv] Specify envKey while loading variables with the dotenv:dump command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants