I'm using the Lumen fraemwork, a microframework by Laravel. The documentation is pretty similar, and I wanted to use Route groups. You can see it's documentation here
The problem I'm having, is, when using route groups, that Laravel tells me I'm having a ReflectionException when I want to call a Controller.
I wanted to build a route, to display all pages from my database. I did it with this route, which works
$app->get('/pages', 'PageController@index');
Now, I also wanted to let users make post/delete requests to the PageController
. Since this would be modifying, I wanted to create a route group, with an api
prefix, so all requests, which are POST
or DELETE
must be made via /api/pages
I did it like this
$app->group(['prefix' => '/api'], function($app){
});
Now, to test if this works generally, I added the get route from above into this group
$app->group(['prefix' => '/api'], function($app){
$app->get('/pages', 'PageController@index');
});
But here, I'm getting the Errror
ReflectionException in Container.php line 736: Class PageController does not exist
Stacktrace
in Container.php line 736
at ReflectionClass->__construct('PageController') in Container.php line 736
at Container->build('PageController', array()) in Container.php line 626
at Container->make('PageController', array()) in Application.php line 393
at Application->make('PageController') in Application.php line 1259
at Application->callControllerAction(array(true, array('uses' => 'PageController@index'), array())) in Application.php line 1232
at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'PageController@index'), array())) in Application.php line 1217
at Application->handleFoundRoute(array(true, array('uses' => 'PageController@index'), array())) in Application.php line 1138
at Application->Laravel\Lumen\{closure}() in Application.php line 1370
at Application->sendThroughPipeline(array(), object(Closure)) in Application.php line 1144
at Application->dispatch(object(Request)) in Application.php line 1084
at Application->run(object(Request)) in index.php line 30
I didn't know if there was something wrong with my routes, or with the framework, so I added this simple route to the group
$app->group(['prefix' => '/api'], function($app){
$app->get('/pages', function(){
print 'test';
});
});
When now calling the api/pages
Endpoint, I'm getting the output. My document says test
. So it seems there is something else wrong. What could it be?