Error while listing routes in an Laravel Api

Asked

Viewed 91 times

0

Personal I am developing a Rest api using Windows and to create this api I am using the tutorial:

when turning the control:

php artisan route:list

I am presented with the following error:

 ReflectionException:Class App\Http\Controllers\pagesController does not exist

 at /var/www/html/freelance/HQ Alma/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:7 
79
775| if ($concrete instanceof Closure) {
776|     return $concrete($this, $this->getLastParameterOverride());
777|}
778|
779|$reflector = new ReflectionClass($concrete);
780|
781|// If the type is not instantiable, the developer is attempting to resolve
782|// an abstract type such as an Interface of Abstract Class and there is
783|// no binding registered for the abstractions so we need to bail out.

 Exception trace:

 1 ReflectionClass::__construct("App\Http\Controllers\pagesController")
  /var/www/html/freelance/HQ Alma/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:779

2 Illuminate\Container\Container::build("App\Http\Controllers\pagesController")
  /var/www/html/freelance/HQ Alma/api/vendor/laravel/framework/src/Illuminate/Container/Container.php:658

Please use the argument -v to see more details.

These are my routes:

Route::group(array('prefix' => 'hqi'), function()
{

  Route::get('/', function () {
     return response()->json(['message' => 'HQI API', 'status' => 
     'Connected']);;
  });

  Route::resource('users', 'UserController');
  Route::resource('pages', 'PagesController');
  Route::resource('palestra', 'PalestrasDivulgacaoController');
});

Route::get('/', function () {
   return redirect('api');
});

Someone would know what it could be?

  • 1

    Apparently Laravel isn’t finding the class PagesController. Check the name, location of the file and if the composer.json is correctly configured, don’t forget to give a dump-autoload afterward

  • Pagescontroller is the controller that I created it doesn’t have to be set in Composer

  • I started from scratch and was testing, and somehow the Variable did not recognize that the controller created existed, after remaking it correctly accepted

  • What was pointed out in the error is that the controller was not found. Initially I deleted the controller and created again and it didn’t work, so I created a new api and tested the process

  • 1

    You can try to execute the command composer dump-autoload and see if Laravel recognizes his route.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.