Skip to content

dump-env shouldn't require env argument in all cases #680

@ostrolucky

Description

@ostrolucky

In all of our projects, when deploying, we generate .env.local file with desired target APP_ENV inside of it. However, when running composer dump-env prod this is ineffective, as APP_ENV defined in .env.local file is rewritten by whatever is passed as an argument.

This causes problems because people expect whatever they define as APP_ENV to be used in resulting application after build is done, but then run into situation when they change APP_ENV into something else then prod, but build still runs composer dump-env prod, resulting in broken expectations.

I realize this argument is important in cases when there are files of format .env.{environment} or .env.{environment}.local, but it should be then required only in such cases when these files exist, otherwise argument shouldn't be needed and whatever is defined in .env.local file should be used IMHO.

I think that command should check if such files exist via glob and if so, attempt to interactively ask user to choose which one do they expect to be used. If running in non-interactive mode (answer is null), then it should throw exception. If there are no such files, just take whatever APP_ENV is defined in other, non-environment specific files (.env, .env.local)

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