流明路由组不适用于命名路由


Lumen route group doesn't work with named route

当我在 Lumen 框架中定义组内的路由时,它在直接闭包但不使用控制器名称时运行良好;我总是得到一个未找到的异常。

//Working
$app->group(['prefix' => 'admin'], function () use ($app) {
    $app->get('users', function ()    {
        //...
    });
});
//Get 'Class ExampleController does not exist'
$app->group(['prefix' => 'admin'], function () use ($app) {
    $app->get('users', ['uses' => 'ExampleController@indexAction']);
});

提前谢谢。

您可以通过添加命名空间来修复它:

$app->group(['prefix' => 'admin', 'namespace' => 'App'Http'Controllers'], function () use ($app) {
    $app->get('users', 'ExampleController@indexAction');
});