diff --git a/Loaders/RoutesLoaderTrait.php b/Loaders/RoutesLoaderTrait.php index ab2bd2ca3..293771bd9 100644 --- a/Loaders/RoutesLoaderTrait.php +++ b/Loaders/RoutesLoaderTrait.php @@ -19,6 +19,10 @@ trait RoutesLoaderTrait */ public function runRoutesAutoLoader(): void { + if (!$this->shouldRegisterRoutes()) { + return; + } + $allContainerPaths = Apiato::getAllContainerPaths(); foreach ($allContainerPaths as $containerPath) { @@ -27,6 +31,15 @@ public function runRoutesAutoLoader(): void } } + private function shouldRegisterRoutes(): bool + { + if ($this->app->routesAreCached()) { + return false; + } + + return true; + } + /** * Register the Containers API routes files * @param string $containerPath