Search code examples
phplaravelcommand-line-interfacelaravel-8laravel-artisan

Laravel 8 config:cache allowing sending emails but can't read env variables after config:cache


hope you are all fine. I am facing an issue when I am running command

php artisan config:cache

email is sending but I can't read env('DB_HOST') variables.

Similarly when I run then this time:

php artisan config:clear

email is not sending, now I can read env('DB_HOST') variables.

I don't understand what is issue.


Solution

  • Read this https://laravel.com/docs/8.x/configuration#configuration-caching

    You must be use correspond config. IN your case

    config('database.connections.mysql.host')