1
votes

I am using Laravel 6.0 and I try to list all my routes with

php artisan route:list

It fails and returns:

      Illuminate\Contracts\Container\BindingResolutionException  : Target class [App\Http\Controllers\Admin\DashboardadController] does not exist.

  at D:\xampp\htdocs\myws\vendor\laravel\framework\src\Illuminate\Container\Container.php:805
    801| 
    802|         try {
    803|             $reflector = new ReflectionClass($concrete);
    804|         } catch (ReflectionException $e) {
  > 805|             throw new BindingResolutionException("Target class [$concrete] does not exist.", 0, $e);
    806|         }
    807| 
    808|         // If the type is not instantiable, the developer is attempting to resolve
    809|         // an abstract type such as an Interface or Abstract Class and there is

  Exception trace:

  1   Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}(Object(Illuminate\Routing\Route))
      [internal]:0

  2   ReflectionException::("Class App\Http\Controllers\Admin\DashboardadController does not exist")
      D:\xampp\htdocs\myws\vendor\laravel\framework\src\Illuminate\Container\Container.php:803

My Route

Route::group([ 'as'=>'admin.', 'prefix'=>'admin', 'namespace'=> 'Admin', 'middleware' => ['auth','admin']],
    function(){
        Route::get('dashboard', 'DashboardadController@index')->name('dashboard');
    });

    Route::group([ 'as'=>'author.', 'prefix'=>'author', 'namespace'=> 'Author', 'middleware' => ['auth','author']],
    function(){
        Route::get('dashboard', 'DashboardauController@index')->name('dashboard');
    });

My RouteServiceProvider

protected $namespace = 'App\Http\Controllers';

Any idea how I could debug this issue?

Many thanks in advance!

2
what is the class name of the Controller you are trying to access, what namespace have you declared it in and what folder is it in?lagbox
check the spelling of your controller in your routes- is it actually "DashboardadController" or should it rather be "DashboardController"?Mhluzi Bhaka

2 Answers

3
votes

Your error is because that you removed DashboardController or changed it's namespace and in somewhere else you imported it and you forgot to remove it's usage or correct it's namespace

When you run php artisan route:list it will execute every controller once and if there is error in any controllers the command will fail and throws the exception so best solution in my opinion is to search in your controllers and find that controller which is causing this error or if you are using a good IDE they usually have a find in path ability that can search a given text in a path or whole project

Edit
Also use this convention to make sure that your namespace is correct
but don't forget to import dashboardcontroller

Route::group([ 'as'=>'admin.', 'prefix'=>'admin', 'middleware' => ['auth','admin']], function(){
        Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard');
    });

    Route::group([ 'as'=>'author.', 'prefix'=>'author', 'middleware' => ['auth','author']], function(){
        Route::get('dashboard', [DashboardController::class, 'index'])->name('dashboard');
    });
0
votes

Try this:

Route::resource('post/', DashboardController::class);