Reputation: 4539
I have these values in my .env file:
APP_IMG_PATH="/img/"
APP_IMG_LOGO="sclogo.png"
Then in my header I do this:
<img src="{!! env('APP_IMG_PATH') . env('APP_IMG_LOGO') !!}" class="navbar-logo"/>
But the log does not show and in Chrome Inspect I get
<img src(unknown) class="navbar-logo">
I tried clearing config cache and recreating it:
php artisan config:cache;
But the result is the same. Any help is appreciated.
Upvotes: 0
Views: 216
Reputation: 35337
Config caching disables env() calls. Any call to env() will return null once the config is cached.
Perhaps a poor choice by the Laravel team, but the idea is to encourage you to use config(), not env() within your code.
Instead, add new lines to your config/app.php (if that's where you choose):
'img_path' => env('APP_IMG_PATH'),
'img_logo' => env('APP_IMG_LOGO'),
Then re-create your config cache and use config('app.img_path')
and config('app.img_logo')
within your application.
Upvotes: 4
Reputation: 2866
After addig new things to env file, you need to clear your cache.
php artisan config:clear
php artisan config:cache
Upvotes: 1