While working in Laravel, if you introduce some key-value in .env file, it won't reflect in your code and would always return null. How to solve this:


Laravel cache your configuration files so the execution become faster. So everytime when you change the configuration files on server, you should clear the cache.


You can clear config cache by using the following command:

php artisan config:clear


And you can use below command to clear and cache configurations:

php artisan config:cache


Additionally you can run these commands also to clear the other caches

/*for clearing the cache*/
php artisan cache:clear

/*for clearing the compiled views*/
php artisan view:clear

/*for clearing the routes cache*/
php artisan route:clear