doucheng7808
2019-06-03 12:18
浏览 116
已采纳

laravel api包不能识别我以前的路线

i have a project that already has some api working and now i wanna use dingo on it to version my apis now i just did all the documentation said and yet i get this error in below :

{
message: "The version given was unknown or has no registered routes.",
status_code: 400,
debug: {
line: 79,
file: "/home/farshad/my-projects/tika_acco/vendor/dingo/api/src/Routing/Adapter/Laravel.php",
class: "Dingo\Api\Exception\UnknownVersionException",
trace: [
"#0 /home/farshad/my-projects/tika_acco/vendor/dingo/api/src/Routing/Router.php(514): Dingo\Api\Routing\Adapter\Laravel->dispatch(Object(Dingo\Api\Http\Request), 'v1')",
"#1 /home/farshad/my-projects/tika_acco/vendor/dingo/api/src/Http/Middleware/Request.php(126): Dingo\Api\Routing\Router->dispatch(Object(Dingo\Api\Http\Request))",
"#2 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(128): Dingo\Api\Http\Middleware\Request->Dingo\Api\Http\Middleware\{closure}(Object(Dingo\Api\Http\Request))",
"#3 /home/farshad/my-projects/tika_acco/vendor/barryvdh/laravel-cors/src/HandleCors.php(36): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))",
"#4 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Barryvdh\Cors\HandleCors->handle(Object(Dingo\Api\Http\Request), Object(Closure))",
"#5 /home/farshad/my-projects/tika_acco/vendor/fideloper/proxy/src/TrustProxies.php(57): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))",
"#6 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Fideloper\Proxy\TrustProxies->handle(Object(Dingo\Api\Http\Request), Object(Closure))",
"#7 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))",
"#8 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Dingo\Api\Http\Request), Object(Closure))",
"#9 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))",
"#10 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\TransformsRequest->handle(Object(Dingo\Api\Http\Request), Object(Closure))",
"#11 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php(27): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))",
"#12 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle(Object(Dingo\Api\Http\Request), Object(Closure))",
"#13 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(62): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))",
"#14 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Dingo\Api\Http\Request), Object(Closure))",
"#15 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Dingo\Api\Http\Request))",
"#16 /home/farshad/my-projects/tika_acco/vendor/dingo/api/src/Http/Middleware/Request.php(127): Illuminate\Pipeline\Pipeline->then(Object(Closure))",
"#17 /home/farshad/my-projects/tika_acco/vendor/dingo/api/src/Http/Middleware/Request.php(103): Dingo\Api\Http\Middleware\Request->sendRequestThroughRouter(Object(Dingo\Api\Http\Request))",
"#18 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(163): Dingo\Api\Http\Middleware\Request->handle(Object(Dingo\Api\Http\Request), Object(Closure))",
"#19 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}(Object(Illuminate\Http\Request))",
"#20 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing\{closure}(Object(Illuminate\Http\Request))",
"#21 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(151): Illuminate\Pipeline\Pipeline->then(Object(Closure))",
"#22 /home/farshad/my-projects/tika_acco/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))",
"#23 /home/farshad/my-projects/tika_acco/public/index.php(55): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))",
"#24 /home/farshad/my-projects/tika_acco/server.php(21): require_once('/home/farshad/m...')",
"#25 {main}"
]
}
}

here is a part of my api.php route


$api->version('v1', function (Router $api) {
    $api->group(['prefix' => 'v1'], function(Router $api) {
        $api->group(['middleware' => 'bindings'], function(Router $api) {
            /*************************************************
             *
             * Accommodation Api Crud
             *
             **************************************************/
            $api->get('accommodationbooking', 'App\\Api\\V1\\Controllers\\AccommodationBookingController@index');

Any one With similar problem ???

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongsuikai8286 2019-06-10 11:21
    已采纳

    when you make new routes for you app you have to cache them again the problem was i didnt know that caching routes and api routes are different so i ran :

    php artisan api:cache
    

    because it clears cache first and cache again after that it will recognize your routes

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题