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

warning no environment specified, defaulting to: development #2264

Open
zkwbbr opened this issue Feb 1, 2024 · 4 comments
Open

warning no environment specified, defaulting to: development #2264

zkwbbr opened this issue Feb 1, 2024 · 4 comments

Comments

@zkwbbr
Copy link

zkwbbr commented Feb 1, 2024

The docs seems outdated.

My config looks like this:

environments:
    default_migration_table: phinxlog
    default_environment: development

But I get a warning: warning no environment specified, defaulting to: development.

How to properly set default_environment?

@MasterOdin
Copy link
Member

MasterOdin commented Feb 1, 2024

The warning is expected if you don't pass --environment to the command, to indicate that it's using the value from default_environment. The only potential change here would be reducing this from a warning to an info message, but this is (to my knowledge) the first time anyone's commented about it being a warning.

@zkwbbr
Copy link
Author

zkwbbr commented Feb 1, 2024

I see that now, maybe change the wording to something like "--environment command not specified, using default_environment from config".

I guess it's not a big deal but initially it looked like it's warning my config file is not properly configured:

warning

@MasterOdin
Copy link
Member

MasterOdin commented Feb 1, 2024

Yeah, all the commands that take an environment option all have the same output if it's omitted:

$output->writeln('<comment>warning</comment> no environment specified, defaulting to: ' . $environment, $this->verbosityLevel);

Looking at git history, it's also been like this since the project's creation 13 years ago.

I think having it be a warning could be useful where in production, where you are expected to use the --environment production flag and if you omit it, you'd want a stronger visual indication that you did that, vs just a comment that's more likely to blur into the rest of the output.

As a middle ground, would updating the docs to indicate that if you omit the environment flag, then a warning will be shown and phinx will use the value of default_environment have helped explain what was going on?

To be clear, I don't have a strong opinion about this one way or the other.

@zkwbbr
Copy link
Author

zkwbbr commented Feb 1, 2024

As a middle ground, would updating the docs to indicate that if you omit the environment flag, then a warning will be shown and phinx will use the value of default_environment have helped explain what was going on?

I guess that's better but TBH I didn't fully read the docs lately, though I have been using phinx for years. Somehow this warning caught my attention in my latest project.

I think the confusion is due to the warning doesn't state where it arises from -- whether its from cmd line flag or config file. I don't usually use --environment flag so to me I thought phinx only sees the config file. Again it's not really a big deal now that I understand it.

On a side note, the docs still says default_migration_table but I think that's deprecated since 0.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants