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 would like to use them in my controller. I've tried this but with no result:
$hostname = config('IMAP_HOSTNAME_TEST');
The $hostname variable is equal to null. How can I use these config variables in my controller?
All of the variables listed in
.env
file will be loaded into the$_ENV
PHP super-global when your application receives a request. Checkout laravel configuration pageInController
In blade.view
May be not related, but it might help someone.... in Laravel just dd(config('app.env')); and you'll see 'local' or 'production'