10

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 ??

Cowboy
  • 272
  • 2
  • 10

2 Answers2

15

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
Community
  • 1
  • 1
owenconti
  • 400
  • 3
  • 6
  • @owenconti +1 Thanks a lot that helped me too – Junior Dec 30 '15 at 17:01
  • @Cowboy - Can you mark my reply as the answer to the question? – owenconti Dec 31 '15 at 18:44
  • This did not work for me as expected when using [homestead](https://github.com/laravel/homestead), because there already was an `APP_ENV` variable populated via php-fpm which could *not* be overridden via .env file. I just wrote a more detailed explanation on the how's and why's [here](http://stackoverflow.com/a/34838187/413531). Long story short: Make sure not to set any environment variables **outside** of .env files if you want to change them **via** .env files. – Hirnhamster Jan 17 '16 at 14:04
  • hey.. check this one my tutorial on how to load multiple environment http://developers.ph/laravel-framework/laravel-5/how-to-setup-multiple-environment-for-laravel-5-developers-way/ – Anthony Pillos Feb 05 '16 at 06:39
0

Sometimes when you changed in your .env file it does not take correct values from that, the problem is due to some configuration cache.Try running following commands, hope will work

php artisan config:cache
php artisan config:clear
php artisan cache:clear
Shahrukh Anwar
  • 2,544
  • 1
  • 24
  • 24