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

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

    In my case same error occurred because of forward slash / but it should be backward slash \ in defining route,

    it happens when you have controller in folder like as in my case controller was in api Folder, so always use backward slash \ while mentioning controller name.

    see example:

    Error-prone code:

    Route::apiResource('categories', 'api/CategoryController');
    

    Solution code:

    Route::apiResource('categories', 'api\CategoryController');
    

提交回复
热议问题