Get environment value in controller

前端 未结 10 1669
既然无缘
既然无缘 2020-12-25 10:43

In my .env file I have the following:

IMAP_HOSTNAME_TEST=imap.gmail.com
IMAP_USERNAME_TEST=myemail@gmail.com
IMAP_PASSWORD_TEST=mypw

Now I

10条回答
  •  庸人自扰
    2020-12-25 11:04

    As @Rajib pointed out, You can't access your env variables using config('myVariable')

    1. You have to add the variable to .env file first.
    2. Add the variable to some config file in config directory. I usually add to config/app.php
    3. Once done, will access them like Config::get('fileWhichContainsVariable.Variable'); using the Config Facade

    Probably You will have to clear config cache using php artisan config:clear AND you will also have to restart server.

提交回复
热议问题