[英]Laravel 5 Dingo API controller
I have been trying to implement a REST API using the Laravel 5 Dingo API package. 我一直在尝试使用Laravel 5 Dingo API包实现REST API。
This is my routing code: 这是我的路由代码:
$api->version('v1', function ($api) {
$api->get('users/{id}', 'Api\V1\UsersController@show');
});
This is my error code: 这是我的错误代码:
{"message":"Class Api\\V1\\UsersController does not exist","code":-1,"status_code":500}
So, where should I place my controller file in order it finds the correct path for my controller ? 那么,我应该在哪里放置我的控制器文件,以便为我的控制器找到正确的路径?
I placed the file in app/http/controllers/Api/V1/
directory but I'm still getting this kind of error. 我将文件放在
app/http/controllers/Api/V1/
目录中,但我仍然遇到这种错误。
I am using Dingo API 0.10 for Laravel. 我正在使用Dingo API 0.10用于Laravel。
By adding full path of the controller in the route 通过在路径中添加控制器的完整路径
$api->get('users/{id}', 'App\\Http\\Controllers\\Api\\V1\\UsersController@show');
will fix this error. 将修复此错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.