简体   繁体   中英

Laravel 5 Dingo API controller

I have been trying to implement a REST API using the Laravel 5 Dingo API package.

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.

I am using Dingo API 0.10 for 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM