Support the ongoing development of Laravel.io →
posted 3 months ago
Cache Routing
Last updated by @tvbeek 3 months ago.
0
moderator

Hello @valen

The cache commando's are only for production because they cache the configuration.

As example, config:cache will cache your config files and if the config is cached your .env file will not be loaded.

Quote from the documentation:

If you execute the config:cache command during your deployment process, you should be sure that you are only calling the env function from within your configuration files. Once the configuration has been cached, the .env file will not be loaded and all calls to the env function for .env variables will return null.

php artisan optimize cache multiple part, see the documentation: https://laravel.com/docs/11.x/deployment#optimization

My advice is to run php artisan optimize:clear on your machine to remove all the cached parts and not run any cache command during development. During the deployment I advice to run php artisan optimize if everything is correctly configured.

ps. I have updated your post to make your commands readable :)

Last updated by @tvbeek 3 months ago.

curioushack liked this reply

1

FYI, the flooring video from LaravelDaily explains why you may want to move the variables out of the env file. This would also potentially resolve the issue you are encountering.

https://www.youtube.com/watch?v=AWTUpT7krAs

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Valen valen Joined 29 Jul 2024

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.