thai6070
thai6070

Reputation: 31

Laravel doesn't read config in .env file

Laravel doesn't read config in env, so env('APP_KEY') always returns NULL. I also use:

php artisan config:clear

and

php artisan config:cache

but it doesn't have any effect. Do you have any solutions to fix? First time, I could fix by using 2 command above, but now I can't.

Upvotes: 0

Views: 1037

Answers (2)

Luis
Luis

Reputation: 41

If you registered the variable in the config/services.php file, make sure to include the word services in your viariable configuration path when calling it.

Example:

config('services.myApp.key');

Upvotes: 0

Rowayda Khayri
Rowayda Khayri

Reputation: 489

Try:

php artisan config:clear

then:

php artisan cache:clear

and make sure that you have permissions to run these commands, or you can simply run them with sudo.

Upvotes: 2

Related Questions