Home > Blockchain >  Issue in accessing server key from env (Laravel)
Issue in accessing server key from env (Laravel)

Time:01-10

I have my server key in .env on production but sometimes notification stops working as server key not accessable .

But when I run the command php artisan config:cache then it again starts working .

CodePudding user response:

Do not access the variable of .env directly in controller or inside any file. First you have to access that variable in any config file. Like below:

For e:g; inside config/app.php define your server key 'server_key' => env('server_key')

after defining above key in config/app.php you have to access it inside any file as below: config('app.server_key')

By doing this you will permanantly resolve your issue.

  • Related