Laravel .env variable always returns null

As per the Laravel document

“Once the configuration has been cached, the .env file will not be loaded and all calls to the env function will return null.”

You can find it here

The Best process is
1. Define the variables in .env file


2. Use this variable in your config file.
=> constant.php file
‘APP_URL’=>env(‘APP_URL’, ‘Not Found’),

3. Call/ access it in your controllers

echo config(‘constant.APP_URL’);

Please follow and like us:

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.