Ad

Get Environment Value In Controller

- 1 answer

In my .env file I have the following:

IMAP_HOSTNAME_TEST=imap.gmail.com
[email protected]
IMAP_PASSWORD_TEST=mypw

Now I would like to use them in my controller. I've tried this, but without any result:

$hostname = config('IMAP_HOSTNAME_TEST');

The $hostname variable is equal to null. How can I use these configuration variables in my controller?

Ad

Answer

Try it with:

<?php $hostname = env("IMAP_HOSTNAME_TEST", "somedefaultvalue"); ?>
Ad
source: stackoverflow.com
Ad