简体   繁体   English

在Laravel 5.1中使用Dingo Pakckage在Rest API中路由错误

[英]Route error in rest api using dingo pakckage in laravel 5.1

I am creating a restful api using laravel dingo package.When i am giving url localhost:8000/hello.it is showing error NotFoundHttpException in RouteCollection.php line 161: 我正在使用laravel dingo包创建一个宁静的api。当我给url localhost:8000 / hello。它在RouteCollection.php第161行中显示错误NotFoundHttpException:

Here is my route.php 这是我的route.php

/* |-------------------------------------------------------------------------- | / * | ------------------------------------------------- --------------------------- | Application Routes |-------------------------------------------------------------------------- | 申请途径| ------------------------------------------------- --------------------------- | | | Here is where you can register all of the routes for an application. 您可以在此处注册应用程序的所有路由。 | | It's a breeze. 轻而易举。 Simply tell Laravel the URIs it should respond to | 只需告诉Laravel它应该响应的URI | and give it the controller to call when that URI is requested. 并向控制器发送请求该URI时调用的控制器。 | | */ * /

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

Route::get('/', function () {
  return view('welcome');
});

$api->version('v1', function($api) {
$api->get('hello', function(){
     return "Hello";
});

   });

Here is my api.php code. 这是我的api.php代码。 I have set my api.php 我已经设置了我的api.php

'transformer' => env('API_TRANSFORMER', Dingo\Api\Transformer\Adapter\Fractal::class),

'formats' => [

    'json' => Dingo\Api\Http\Response\Format\Json::class,

],

'domain' => env('API_DOMAIN', 'api.restapi.com'),
'name' => env('API_NAME', 'rest api'),
   'version' => env('API_VERSION', 'v1'),

After giving route it is showing error.i have tried in every possible way.please help me out. 给出路线后显示错误。我已经尽一切可能尝试了。请帮帮我。 Thank you in advance. 先感谢您。

If you have prefix API_PREFIX set then the route you've added corresponds to 如果您设置了前缀API_PREFIX则添加的路由对应于

https://localhost:8000/api/v1/hello

Assuming the prefix is api 假设前缀是api

If no prefix is set then it's 如果未设置前缀,则为

https://localhost:8000/v1/hello

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

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