laravel api软件包无法识别我以前的路线

时间:2019-06-03 12:18:43

标签: php laravel

我有一个已经有一些api工作的项目,现在我想在它上使用dingo来版本我的api,我刚才做了所有文档,但是在下面却遇到了这个错误:

{
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}"
]
}
}

这是我api.php路由的一部分


$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');

有类似问题的人吗?

1 个答案:

答案 0 :(得分:0)

当您为应用程序创建新路由时,您必须再次缓存它们,问题是我不知道缓存路由和api路由是不同的,所以我运行了:

php artisan api:cache

因为它会先清除缓存,然后再缓存,然后才能识别您的路由