create 2 route files routes.web.php
and routes.api.php
.
edit the RouteServiceProvider.php
file to look like the example below:
<?php
namespace AppProviders;
use IlluminateFoundationSupportProvidersRouteServiceProvider as ServiceProvider;
use IlluminateRoutingRouter;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $webNamespace = 'AppHttpControllersWeb';
protected $apiNamespace = 'AppHttpControllersApi';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param IlluminateRoutingRouter $router
*
* @return void
*/
public function boot(Router $router)
{
//
parent::boot($router);
}
/**
* Define the routes for the application.
*
* @param IlluminateRoutingRouter $router
*
* @return void
*/
public function map(Router $router)
{
/*
|--------------------------------------------------------------------------
| Web Router
|--------------------------------------------------------------------------
*/
$router->group(['namespace' => $this->webNamespace], function ($router) {
require app_path('Http/routes.web.php');
});
/*
|--------------------------------------------------------------------------
| Api Router
|--------------------------------------------------------------------------
*/
$router->group(['namespace' => $this->apiNamespace], function ($router) {
require app_path('Http/routes.api.php');
});
}
}
Note: you can add as many route files as you want...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…