Antoine Bellion
Antoine Bellion

Reputation: 136

Lumen route group doesn't work with named route

When I define a route inside a group in Lumen framwork it's working well with a direct closure but not with a controller name ; I always get a not found exception.

//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']);
});

Thanks in advance.

Upvotes: 2

Views: 5056

Answers (1)

AKosarek
AKosarek

Reputation: 191

You can fix it by adding a namespace:

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

Upvotes: 4

Related Questions