Laravel 6.0 php artisan route:list returns “Target class [App\Http\Controllers\SessionsController] does not exist.”

后端 未结 17 1845
無奈伤痛
無奈伤痛 2021-02-05 10:36

I am using Laravel 6.0 and I try to list all my routes with artisan route:list, but it fails and returns:

Illuminate\\Contracts\\Container\\

相关标签:
17条回答
  • 2021-02-05 11:17

    on Larave 7 I had the same issue.

    I checked the spelling of the controller name.

    I recognize I have the wrong spelling in the "AlbumContoller" and I rename it to "AlbumController". so I forgot "r"

    after I renamed the file and controller name and controller name in the web.php

    Route::resource('albums', 'AlbumsController');
    

    everything worked well

    So You Don't need these two:

    1- use App\Http\Controllers\IndexContoller;

    2- Route::get('/', [MyModelController::class, 'myFunction']);

    0 讨论(0)
  • 2021-02-05 11:24

    replace-

    Route::resource('/admin/UserOff','admin/UsersController');
    

    with-

    Route::resource('/admin/UserOff','admin\UsersController');
    

    forward / with \

    0 讨论(0)
  • 2021-02-05 11:24

    This is the perfect answer, I think:

    • Option 1:
    use App\Http\Controllers\HomepageController;
    Route::get('/', [HomepageController::class, 'index']);
    
    • Option 2:
    Route::get('/', 'App\Http\Controllers\HomepageController@index');
    
    0 讨论(0)
  • 2021-02-05 11:25

    Alright i got similar problem, i was trying to be smart so i wrote this in my web.php

    Route::group([
        'middleware'    => '', // Removing this made everything work
        'as'            => 'admin.',
        'prefix'        => 'admin',
        'namespace'     => 'Admin',
    ],function(){
    
    });
    

    All i had to do is just to remove all the unnecessary/unused option from group. That's all.

    0 讨论(0)
  • 2021-02-05 11:25

    You can define a route to this controller action like so:

    use App\Http\Controllers\UserController;

    Route::get('user/{id}', [UserController::class, 'show']);

    0 讨论(0)
提交回复
热议问题