0
路線這是我RouteServiceProvider
,我已經改變了用於創建多個路由文件。創建多個文件diffrentiate在laravel 5.4
namespace App\Providers;
use Illuminate\Routing\Router;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider {
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot(Router $router) {
//
parent::boot($router);
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map(Router $router) {
$this->mapApiRoutes($router);
$this->mapWebRoutes($router);
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes($router) {
$router->group(['namespace' => $this->namespace, 'middleware' => 'web'], function ($router) {
foreach (glob(app_path('Http/Routes/Web/*.php')) as $eachRoute) {
require $eachRoute;
}
});
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes($router) {
$router->group(['prefix' => 'api', 'namespace' => $this->namespace, 'middleware' => 'api'], function ($router) {
foreach (glob(app_path('Http/Routes/Api/*.php')) as $eachRoute) {
require $eachRoute;
}
});
}
}
對不起,我沒有提到的錯誤對於這一點,基本上我無法重寫引導方法,因爲在laravel 5.4,有是使用用於等作爲laravel 5.1同一目錄中創建多個路由沒有Router類 – Harry