【发布时间】:2020-12-18 09:04:34
【问题描述】:
我正在使用 Laravel 7.0,我尝试使用 artisan route:list 列出我的所有路线,但它失败并返回: Illuminate\Contracts\Container\BindingResolutionException
Target class [App\Http\Controllers\API\RolesController] does not exist.
at C:\xampp\htdocs\Cleanpro\vendor\laravel\framework\src\Illuminate\Container\Container.php:811
807|
808| try {
809| $reflector = new ReflectionClass($concrete);
810| } catch (ReflectionException $e) {
> 811| throw new BindingResolutionException("Target class [$concrete] does not exist.",
0, $e);
812| }
813|
814| // If the type is not instantiable, the developer is attempting to resolve
815| // an abstract type such as an Interface or Abstract Class and there is
1 [internal]:0
Illuminate\Foundation\Console\RouteListCommand::Illuminate\Foundation\Console\{closure}
(Object(Illuminate\Routing\Route))
2 C:\xampp\htdocs\Cleanpro\vendor\laravel\framework\src\Illuminate\Container\Container.php:809
ReflectionException::("Class App\Http\Controllers\API\RolesController does not exist")
我的 api 路线:
Route::post('role','API\RolesController@store');
【问题讨论】:
-
RolesController.php文件中的命名空间是什么?确保它是App\Http\Controllers\API -
检查 RoleController 中的命名空间
-
是的:命名空间 App\Http\Controllers\API;
-
显示
RolesController.php的代码