-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
Hi,
internachi/modular v1.12.0I’m currently using Laravel 8.75, where the RouteServiceProvider still exists. I noticed that when I add routes to a module’s route file (for example, app-modules/core/routes/core-routes.php) and group them with middleware such as auth, they don’t work as expected.
Example:
// app-modules/core/routes/core-routes.php
Route::group(['middleware' => 'auth'], function () {
Route::get('/core', [CoreController::class, 'index']);
});This route never gets recognized when accessed, but if I manually load the module route files from the RouteServiceProvider like this:
$modules_path = base_path('app-modules');
$modules = glob($modules_path . '/*', GLOB_ONLYDIR);
foreach ($modules as $module_path) {
$routes_path = $module_path . '/routes';
if (!is_dir($routes_path)) {
continue;
}
foreach (glob($routes_path . '/*.php') as $route_file) {
Route::middleware('web')
->namespace($this->namespace)
->group($route_file);
}
}then the routes (including those using auth middleware) start working properly.
So I’m wondering:
- Is it necessary to manually add module route files (like
modulename-routes.php) to theRouteServiceProviderfor them to work? - Or should the package handle this automatically?
- The documentation doesn’t seem to mention anything about middleware behavior in module routes, so I’m not sure if I’m missing a configuration step.
Thanks in advance for clarifying.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels