简体   繁体   English

Dingo API未注册路线

[英]Dingo api not registering routes

Hi i'm using Dingo Api dev-master b36db17 (1.0.*@dev) with Laravel 5.2.11 嗨,我在Laravel 5.2.11中使用了Dingo Api开发大师b36db17(1.0.*@dev)

When i try to acces my api routes i get an error : 当我尝试访问我的api路由时,出现错误:

"The version given was unknown or has no registered routes." (status:400)

here is my api route: 这是我的api路线:

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', ['version' => 'v1', 'prefix' => 'api'], function ($api) {

  Route::group(['prefix' => 'api', 'version' => 'v1'], function () {
    //# Version 1 routes here
    Route::post('login', [  
      'uses'      => 'App\Api\V1\Http\Controllers\AuthenticateController@authenticate',
      'as'        => 'api.login'
      ]);
  });
});

the command php artisan api:routes shows nothing php artisan api:routes命令什么也没显示

I need some help please 我需要一些帮助

Edit - 27/01/16 编辑-16/01/16

What is the purpose of the adapter ? 适配器的作用是什么?

it looks like the routes are not loaded : 似乎未加载路线:

class Laravel implements Adapter in namespace Dingo\\Api\\Routing\\Adapter 类Laravel在名称空间Dingo \\ Api \\ Routing \\ Adapter中实现Adapter

public function dispatch(Request $request, $version)
{
    if (! isset($this->routes[$version])) {
        var_dump($this->routes);
        throw new UnknownVersionException;
    }
    [...]
}

problem auto-resolved : to declare my routes, i used the Route facade instead of the Dingo api router (Dingo has its own router since a recent version) 问题自动解决:为了声明我的路线,我使用了Route门面而不是Dingo api路由器(自最新版本以来,Dingo拥有自己的路由器)

so i replaced Route::group( and Route::get( 所以我替换了Route::group(Route::get(

by $api->get( and $api->get( 通过$api->get($api->get(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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