ENV variables remain the same after clearing cache
I've been doing some email testing with mailtrap. I've now decided to change my .env credentials to those from my mailgun account. I've also changed my app name.
Yet after doing so and clearing my cache using php artisan config:clear and php artisan cache:clear. My email is still being sent on mailtrap with my old app name. Even though I changed the credentials from mailtrap to mailgun.
I thought this would be all I have to do for my changes to take place. What else do I have to do?
First for my experience, the artisan commands can trick you a bit. If you are using the file system as the cache driver, make sure you have permissions to delete the files within the storage/framework/cache folders.
For example: running php artisan cache:clear on terminal looks good but no real effect is noticed. When entering tinker and running Cache::clear() all the unix permission issues are visible, it just happens the command line was suppressing them.
Second, the app name was changed. When using Redis as the cache mechanism the app name is part of the key stored in the cache. Although it's a brand new one and things should be pointed to the new key-value pairs, I would clear the Redis database just in case.
Thanks for the tip. I'll definitely be using that. However, when I run that command in tinker it shows my new app name. Yet, when using ```{{ config('app.name') }} in my email template, it sends me the email with the old app name. This doesn't make sense to me. How about you?
I've ran Cache::clear() in tinker and it returns true. So it's definitely been cleared? I've never used Redis and I'm not sure how I would clear it anyway. Unless that's what Laravel uses by default?
It looks odd. But do notice that by running php artisan config:cache, the php artisan config:clear is also run under the hood. In fact, is the first thing that is executed. You can check for yourself at the file Illuminate/Foundation/Console/ConfigCacheCommand.php.
I'm getting the exact same problem now with Stripe. Config:clear will allow me to change my app.name but not my stripe.key. I'm checking in Tinker with config('stripe.key'). What's going on here??
No. I'm running it on localhost. I've tested it on a couple of different apps and the same thing happens. When you run config('db.connection') null is returned.
But when you run config('mail.host') your host is returned (in my case smtp.mailtrap.io).
I'm guessing that the value of some keys can't be accessed through tinker for security reasons?