Reputation: 229
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
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