Dom
Dom

Reputation: 3444

Laravel 5.5 : cannot read a variable from .env file

In Laravel 5.5 when I do a simple :

$env = env('APP_ENV');
Log::info('environnement : ' . $env);

The log is always :

[2018-08-23 11:55:34] local.INFO: environnement :   

And my .env file is :

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:+WXI)---hidden-----IXBfB2jTYAqo=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost:3000/

I am waiting for a response : "local". And don't understand why I receive null.

Upvotes: 0

Views: 225

Answers (2)

Sang Nguyen
Sang Nguyen

Reputation: 1720

Did you try to clear cache?

php artisan config:clear

If you run your web using command php artisan serve, please close then run again.

Upvotes: 4

matiit
matiit

Reputation: 8017

You should be using getenv() function, not env() one.

Upvotes: 0

Related Questions