Route Caching
Reflecting over controller classes on every request adds overhead. Route caching compiles the route map once and stores it as a plain PHP file.
Manual Caching
Section titled “Manual Caching”$cachePath = __DIR__ . '/../storage/cache/routes.php';
if (file_exists($cachePath)) { $router->loadFromCache($cachePath);} else { $router->register(UserController::class); $router->register(PostController::class); $router->saveToCache($cachePath);}Automatic Caching (Framework)
Section titled “Automatic Caching (Framework)”When using the full Antares framework, caching is handled automatically when APP_ENV=production:
- On boot, if
storage/cache/routes.phpexists and the fingerprint still matches, routes are loaded from the cache. - Otherwise the route providers run, and the result is written to the cache.
The fingerprint is a hash of composer.lock, .env, and every file under app/, so changing any of them rebuilds the cache on the next boot.
Clear the cache manually (run from the project root):
php vendor/bin/antares cache:clear