I am working on a API for 2 client application, mobile application and angular2 admin panel.
If I write the routes for both application in a single default routes/api.php
, this will be very huge.
So, I want to split the api routes file as :
routes/admin.api.php
for angular approutes/app.api.php
for mobile app
I have modified the RouteServiceProvide
as below
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
protected $namespace = 'App\Http\Controllers';
public function boot()
{
//
parent::boot();
}
public function map()
{
$this->mapAdminApiRoutes();
$this->mapApiRoutes();
$this->mapWebRoutes();
//
}
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
protected function mapApiRoutes()
{
Route::prefix('api/v1')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
protected function mapAdminApiRoutes()
{
Route::prefix('api/v1')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/admin.api.php'));
}
}
I'm getting the following error
(1/1) FatalErrorException
Illuminate\Routing\Router::loadRoutes(): Failed opening required 'D:\Workspace\Project Izzmart\izzmartoutes/api.php' (include_path='.;C:\php\pear')
in Router.php (line 329)