Config and Route Caching

Configuration and Route Caching

php artisan config:cache merges every config file into bootstrap/cache/config.php. While that file exists, LoadConfiguration loads it instead and LoadEnvironmentVariables skips .env entirely, as a route returning config('bookshop.free_shipping_over') and env('BOOKSHOP_FREE_SHIPPING_OVER') shows:

The same request before and after config:cacheShell
curl -s localhost:8302/shipping; echo
php artisan config:cache
curl -s localhost:8302/shipping; echo
Output
{"config":150,"env":"150"}
   INFO  Configuration cached successfully.
{"config":150,"env":null}

So code calling env() at runtime works locally and gets null in production. The cache cut LoadEnvironmentVariables from 1.01 ms to 0.12 ms and LoadConfiguration from 2.05 ms to 0.51 ms. php artisan route:cache writes bootstrap/cache/routes-v7.php; closure routes cache too, under names such as generated::GasuRPqun1cKpg3p (Debugging Routes). php artisan optimize builds the config, event, route and view caches at deploy time (Production Deployment); optimize:clear removes them all.