Replies: 2 comments 3 replies
-
I suppose something like that may fulfill this suggestion, but how to test it? protected function registerRoutes(): void
{
if (! config('route-attributes.enabled') || $this->app->routesAreCached()) {
return;
}
$routeRegistrar = (new RouteRegistrar(app()->router))
->useRootNamespace(app()->getNamespace())
->useMiddleware(config('route-attributes.middleware') ?? []);
collect($this->getRouteDirectories())->each(fn (string $directory) => $routeRegistrar->registerDirectory($directory));
} |
Beta Was this translation helpful? Give feedback.
-
Hello, Thanks for merging. I have seen your modifications and I just wonder why preferred a method with two About my check with |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm not sure it's an "issue" strictly saying, but it would be nice to avoid re-parsing controller files when routes are cached. I don't know how fast registering routes is, but I think it's always a gain to avoid re-parsing.
In service provider class, this method is defined to register routes:
Laravel
Application
class offers public methodroutesAreCached()
to find out if route registration is required, so I think it's not difficult to add this check. I'd like to do it and make a pull request, but I don't know what kind of test can ensure this behavior.So I prefer let you have a look, to avoid an useless pull request without any test.
Regards.
Raphael Jorel
Beta Was this translation helpful? Give feedback.
All reactions