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

Laravel 9 command serve does not use custom .env file #40978

Closed
fbsanchez opened this issue Feb 12, 2022 · 5 comments
Closed

Laravel 9 command serve does not use custom .env file #40978

fbsanchez opened this issue Feb 12, 2022 · 5 comments
Labels

Comments

@fbsanchez
Copy link

  • Laravel Version: 9.0.1
  • PHP Version: 8.0.15
  • Database Driver & Version: php-mysqlnd-8.0.15-1.fc35 connected to mysql:8 (docker) / sqlite3

Description:

command php artisan serve --env=testing seems not to be working since it is still using default .env file instead.

Steps To Reproduce:

With mysql running using default .env file (configured against mysql)
image

With mysql stopped using custom .env.testing file (configured against sqlite)
image

With mysql stopped moving .env.testing to .env file
image

Another easy test is not having a .env file at all and specify custom one:

image

This time results into a err 500

local.ERROR: No application encryption key has been specified. {"exception":"[object] (Illuminate\\Encryption\\MissingAppKeyException(code: 0): No application encryption key has been specified. at /tmp/laravel-serve-bug/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:79)

Thanks

@fbsanchez
Copy link
Author

Git repository with the code used to take the screenshots:

https://github.com/fbsanchez/laravel-serve-bug

@fbsanchez
Copy link
Author

Thought this issue affects https://github.com/laravel/laravel instead but I didn't see how to report it 😅

@driesvints
Copy link
Member

@ugorur seems like your PR broke this? #37142. Can you confirm you added a bad negation there?

@driesvints driesvints added the bug label Feb 14, 2022
@driesvints driesvints linked a pull request Feb 14, 2022 that will close this issue
@taylorotwell
Copy link
Member

I actually can't recreate the issue. Does your .env.testing file actually contain APP_ENV=testing. If not - add it - that solves the root issue for me.

@fbsanchez
Copy link
Author

Hello @taylorotwell by adding APP_ENV=testing instead local this seems to be working fine

Thank you!

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

Successfully merging a pull request may close this issue.

3 participants