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

App::environment() ignores APP_ENV when --env option is used on cli #28854

Closed
redelschaap opened this issue Jun 15, 2019 · 6 comments
Closed
Labels

Comments

@redelschaap
Copy link
Contributor

  • Laravel Version: 5.8.15
  • PHP Version: 7.3.4

Description:

The documentation says that "The current application environment is determined via the APP_ENV variable from your .env file.". It also says that "The current application environment detection can be overridden by a server-level APP_ENV environment variable."

However, when using artisan with the --env option, App::environment() will return the value of the --env option. To me as a developer, I find it logical that the --env option is used to determine the .env file to use, not to overrule the environment. After all, the name of the .env file can differ from the APP_ENV value in that file.

Steps To Reproduce:

  1. Copy the .env file to .env.foo;
  2. Change the value of APP_ENV within .env.foo to bar;
  3. Run php artisan tinker;
  4. Execute the command App::environment(), the value of APP_ENV should be returned;
  5. Quit Tinker and run php artisan tinker --env=foo;
  6. Execute the command App::environment();
  7. foo is now returned, instead of bar.
@khflab
Copy link

khflab commented Jun 16, 2019

  • Laravel Version: 5.8.17
  • PHP Version: 7.1.13
  • OS: Windows 10

I was able to reproduce it

@driesvints
Copy link
Member

I can't test this atm because my tinker environment is still broken after bobthecow/psysh#540 so it would be cool if some more people could verify this.

@driesvints driesvints added the bug label Jun 24, 2019
@rdarcy1
Copy link
Contributor

rdarcy1 commented Jun 24, 2019

I can reproduce

  • Laravel Version: 5.8.24
  • PHP Version: 7.2.17
  • OS: MacOS 10.14

It seems like this is expected functionality (see Illuminate\Foundation\EnvironmentDetector) but perhaps there should be different flags for the .env file and the value of APP_ENV?

@redelschaap
Copy link
Contributor Author

I think that will be a good solution.

@Tarasovych
Copy link

#28668 related a bit

@driesvints
Copy link
Member

Going to close this as we don't consider this a bug. Please see the remark by Taylor here: #28982 (comment)

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

No branches or pull requests

5 participants