I can see this in RouteServiceProvider.php
:
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
But when I try to add one:
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('themes/myTheme/web.php'));
Then it doesn't pick up the second web.php
file. But if I remove the first web.php
reference, then the second one is picked up. So it seems Laravel only wants one web.php
. However, even this doesn't work:
Route::middleware('myTheme')
->namespace($this->namespace)
->group(base_path('themes/myTheme/web.php'));
Is there any way to get a second web.php file to work?
I've tried/considered:
- A workaround by including the web.php file from the main web.php file. But I'd prefer it if the route provider handled it.
Any ideas?
UPDATE 1
I tried this but it doesn't seem to work for Laravel 8:
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(function ($router) {
require base_path('routes/admin.php');
require base_path('routes/category.php');
});
}