Jayaram Venkat Jayaram Venkat - 4 months ago 106
PHP Question

Lumen 5.3 route not working

I am developing Lumen REST API for ecom website. Suddenly my app crash. I have updated my composer and all stuff. But I can’t find where is the error. But its shows in controller file only.

Error :

ReflectionException in Container.php line 749:Class App\Http\Controllers\App\Http\Controllers\SubcatController does not exist

1. in Container.php line 749
2. at ReflectionClass->__construct('App\Http\Controllers\App\Http\Controllers\SubcatController') in Container.php line 749
3. at Container->build('App\Http\Controllers\App\Http\Controllers\SubcatController', array()) in Container.php line 644
4. at Container->make('App\Http\Controllers\App\Http\Controllers\SubcatController', array()) in Application.php line 211
5. at Application->make('App\Http\Controllers\App\Http\Controllers\SubcatController') in RoutesRequests.php line 680
6. at Application->callControllerAction(array(true, array('uses' => 'App\Http\Controllers\App\Http\Controllers\SubcatController@all'), array())) in RoutesRequests.php line 647
7. at Application->callActionOnArrayBasedRoute(array(true, array('uses' => 'App\Http\Controllers\App\Http\Controllers\SubcatController@all'), array())) in RoutesRequests.php line 632
8. at Application->handleFoundRoute(array(true, array('uses' => 'App\Http\Controllers\App\Http\Controllers\SubcatController@all'), array())) in RoutesRequests.php line 529
9. at Application->Laravel\Lumen\Concerns\{closure}(object(Request))
10. at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
11. at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request)) in ExampleMiddleware.php line 30
12. at ExampleMiddleware->handle(object(Request), object(Closure)) in Pipeline.php line 137
13. at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
14. at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
15. at Pipeline->Laravel\Lumen\Routing\{closure}(object(Request)) in Pipeline.php line 104
16. at Pipeline->then(object(Closure)) in RoutesRequests.php line 782
17. at Application->sendThroughPipeline(array('App\Http\Middleware\ExampleMiddleware'), object(Closure)) in RoutesRequests.php line 535
18. at Application->dispatch(null) in RoutesRequests.php line 476
19. at Application->run() in index.php line 28

Please help me.


Without seeing your route definition with just that error it looks like you are defining the namespace of the controller in the route. Lumen automatically assumes all your controllers reside in App\Http\Controllers.

I have to assume you are doing this:

$app->get('myroute', ['as' => 'my.route', 'uses' => 'App\Http\Controllers\SubcatController']);

When it should be:

$app->get('myroute', ['as' => 'my.route', 'uses' => 'SubcatController']);