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

后端 未结 17 2081
無奈伤痛
無奈伤痛 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:07

    I am running Laravel 8.x on my pc. This error gave me headache. To recreate the error, this is what I did: First I created a controller called MyModelController.php Secondly, I wrote a simple function to return a blade file containing 'Hello World', called myFunction. Lastly, I created a Route: Route::get('/','MyModelController@myFunction'); This did not work.

    This was how I solved it. First you would have to read the documentation on: (https://laravel.com/docs/8.x/releases#laravel-8)

    At the 'web.php' file this was the Route i wrote to make it work:

    use App\Http\Controllers\MyModelController;

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

提交回复
热议问题