2

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.

patricus
  • 59,488
  • 15
  • 143
  • 145
Antoine Bellion
  • 136
  • 1
  • 9

1 Answers1

4

You can fix it by adding a namespace:

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