I added this variable to .env file
STRIPE_SECRET=a12345
I would like to dump the variable using routes/web.php
&
The main reason upon your issue is that you are caching your configuration. When running php artisan config:cache
you're storing your configuration in your cache, and the next time Laravel will boot up it won't read the .env
file because it detects that the configuration has been stored in the cache. Environment file should be used only to setup configuration files and then to access the value you're looking for you should use ONLY the config
method.
Let's assume that you have the file config/stripe.php
that consists of this content:
<?php
return [
'secret' => env('STRIPE_SECRET', '')
];
Once you run php artisan config:cache
access this value using ONLY the syntax config('stripe.secret')
through your application code. Every time you update your config files and your .env
you need to run php artisan config:cache
again.