Laravel says application is in production but APP_ENV is local

Viewed 783

My Laravel .env:

APP_ENV=local
APP_KEY=base64:7HjBWArUX989c8K87678687m2+6786876hs=
APP_DEBUG=true
APP_URL=http://localhost
...

I get the following message if I do php artisan env.

Current application environment: production

Even if I set the default environment to local in the app.php config file, the application still think it is in production. This is driving me nuts. Anyone knows why this is happening and how to fix it? I have run the clean cache commands, optimize commands, etc. I deleted the bootstrap folder content manually, and still nothing.

2 Answers

Are use already run:

php artisan config:cache
php artisan config:clear

?

Update

In my opinion, there are only two reasons why you get production. 1) Something is wrong in your config/app.php in this line: 'env' => env('APP_ENV', 'production'), 2) Or something is broken in your .env file. Make sure you really have an .env file. If there is nothing wrong in your env file. And if in your app.php file this line is correct: 'env' => env('APP_ENV', 'production')

In my case, despite clearing the cache, my app env wasn't changing. I realized when I stopped php artisan serve and started it again the change in my .env file was reflected.

As to why that's the case I don't know yet, I will update this once I find out why.

Related