Reputation: 136
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
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