Ad

After Upgrading Laravel 5.1 To 5.2 \App::environment() Always Returning "production"

- 1 answer

I upgraded laravel 5.1 to 5.2, everything looks good. But when try to access the app environment not getting what expected.

When i dd($_ENV) this is what i get 
"APP_ENV" => "vagrant"
"APP_DEBUG" => "true"
"DB_HOST" => "localhost"  

But When dd(\App::environment());
"production"

P.S. even I checked in tinker: dd(env('APP_ENV')) gives me "vagrant"
but dd(\App::environment()) gives me "production".
Dont you think it is odd :(

This is wierd :(

Anyone face this problem ??

Ad

Answer

you missed a step in the upgrade process:

Configuration

Environment Value

Add an env configuration option to your app.php configuration file that looks like the following:

'env' => env('APP_ENV', 'production'),

P.S. You can check the value from the artisan command:

php artisan env
Ad
source: stackoverflow.com
Ad