TrickStar
TrickStar

Reputation: 229

Didn't get env file value in Controller

I am facing one weird issue in laravel. I am fetching a value from env file into my controller. but I didn't get any value from my env file.

Key name in env file.

MYKEY=XXXXXXXXXXXXXX

Getting key value from my controller file like this. My laravel version in 5.6

$key = env('MYKEY');

Thanks in Advance

Upvotes: 1

Views: 6927

Answers (1)

user10186369
user10186369

Reputation:

You should try this:

php artisan cache:clear

$key = env('MYKEY');

OR

You can set your env variable in config file

config/app.php
'mykey' => env('MYKEY'),

then set your config variable in your code like:

use Config;

$key = Config:get('app.mykey');

Upvotes: 3

Related Questions