我已经在 laravel/lumen 中声明了一个路由组,如下所示:
$app->group(['middleware' => 'auth'], function () use ($app) {
$app->get('/details', 'UserController@details');
});
路由文件 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', 'UserController@details');
});
我收到一个错误Call to undefined method Laravel\Lumen\Application::group()
如何使用中间件添加路由组?