Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After upgrading laravel 5.1 to 5.2 \App::environment() always returning "production"

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

like image 363
Cowboy Avatar asked Dec 28 '15 18:12

Cowboy


People also ask

How can I get current environment in laravel?

In Laravel 4 and 5, the Laravel official docs suggest using: $environment = App::environment();

Where is .ENV file in laravel?

In a fresh Laravel installation, the root directory of your application will contain a .env.example file that defines many common environment variables.

What does PHP artisan config cache do?

php artisan config:cache This command clears the cached config file as mentioned above and recaches the latest configurations into a single file again.


1 Answers

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
like image 64
owenconti Avatar answered Sep 25 '22 20:09

owenconti