我已經宣佈的路線組laravel /流明像這樣未定義的方法Laravel \流明\應用::組():路線集團流明錯誤呼叫到
$app->group(['middleware' => 'auth'], function() use ($app) {
$app->get('/details', '[email protected]');
});
路由文件web.php的全部內容就像這樣:
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It is a breeze. Simply tell Lumen the URIs it should respond to
| and give it the Closure to call when that URI is requested.
|
*/
$app = app();
$router->get('/', function() use ($router) {
return $router->app->version();
});
$app->group(['middleware' => 'auth'], function() use ($app) {
$app->get('/details', '[email protected]');
});
上撥打電話,以http://THE_URL/
我得到一個錯誤Call to undefined method Laravel\Lumen\Application::group()
如何添加路由組與中間件?
你檢查嗎? https://lumen.laravel.com/docs/5.2/routing#route-groups,雖然它看起來與你所做的不一樣。 –
等待!你必須添加'$ app = app(); $路由器 - >獲取( '/',()的函數使用($路由器){ 回報$路由器 - > APP->版本(); });'? –
@OmisakinOluwatobi是的,我檢查了網址,你在第二個評論中提到的部分是在流明中定義的默認路由,我也添加了'$ app = app();',因爲它沒有被發現 –