2017-12-17 25 views
0

Laravel에서 API 경로에 오류가 발생했습니다. 나는 Dingo 패키지를 사용했다. 그것을 성공적으로 설치했고, app.php에 추가했고, artisan에 의해 api.php를 생성했습니다.Laravel에서 API 경로에 오류가 발생했습니다.

라우터 파일에서 코드는 다음과 같습니다 -

PHP는 장인 API를 사용하여 확인에
use Dingo\Api\Routing\Helpers; 

$api = app('Dingo\Api\Routing\Router'); 
/*$api = app('Dingo\Api\Facade\Route');*/ 


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

이 같은 경로 내가 무엇입니까 경로/API/루트 /. 그러나 URL에 도달하면 다음과 같이 오랜 오류가 있습니다. -

{"message":"404 Not Found","status_code":404,"debug":{"line":179,"file":"\/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/RouteCollection.php","class":"Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException","trace":["#0 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(612): Illuminate\\Routing\\RouteCollection->match(Object(Dingo\\Api\\Http\\Request))","#1 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(601): Illuminate\\Routing\\Router->findRoute(Object(Dingo\\Api\\Http\\Request))","#2 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Router.php(590): Illuminate\\Routing\\Router->dispatchToRoute(Object(Dingo\\Api\\Http\\Request))","#3 \/var\/www\/html\/exam\/vendor\/dingo\/api\/src\/Routing\/Adapter\/Laravel.php(81): Illuminate\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#4 \/var\/www\/html\/exam\/vendor\/dingo\/api\/src\/Routing\/Router.php(512): Dingo\\Api\\Routing\\Adapter\\Laravel->dispatch(Object(Dingo\\Api\\Http\\Request), 'v1')","#5 \/var\/www\/html\/exam\/vendor\/dingo\/api\/src\/Http\/Middleware\/Request.php(126): Dingo\\Api\\Routing\\Router->dispatch(Object(Dingo\\Api\\Http\\Request))","#6 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(114): Dingo\\Api\\Http\\Middleware\\Request->Dingo\\Api\\Http\\Middleware\\{closure}(Object(Dingo\\Api\\Http\\Request))","#7 \/var\/www\/html\/exam\/vendor\/fideloper\/proxy\/src\/TrustProxies.php(56): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#8 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(149): Fideloper\\Proxy\\TrustProxies->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#9 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#10 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#11 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/TransformsRequest.php(30): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#12 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#13 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#14 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\ValidatePostSize->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#15 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Middleware\/CheckForMaintenanceMode.php(46): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#16 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(149): Illuminate\\Foundation\\Http\\Middleware\\CheckForMaintenanceMode->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#17 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(102): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Dingo\\Api\\Http\\Request))","#18 \/var\/www\/html\/exam\/vendor\/dingo\/api\/src\/Http\/Middleware\/Request.php(127): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#19 \/var\/www\/html\/exam\/vendor\/dingo\/api\/src\/Http\/Middleware\/Request.php(103): Dingo\\Api\\Http\\Middleware\\Request->sendRequestThroughRouter(Object(Dingo\\Api\\Http\\Request))","#20 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(149): Dingo\\Api\\Http\\Middleware\\Request->handle(Object(Dingo\\Api\\Http\\Request), Object(Closure))","#21 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Routing\/Pipeline.php(53): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))","#22 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Pipeline\/Pipeline.php(102): Illuminate\\Routing\\Pipeline->Illuminate\\Routing\\{closure}(Object(Illuminate\\Http\\Request))","#23 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Kernel.php(151): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))","#24 \/var\/www\/html\/exam\/vendor\/laravel\/framework\/src\/Illuminate\/Foundation\/Http\/Kernel.php(116): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))","#25 \/var\/www\/html\/exam\/public\/index.php(55): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))","#26 \/var\/www\/html\/exam\/server.php(21): require_once('\/var\/www\/html\/e...')","#27 {main}"]}} 
+0

'php artisan route : list'는 당신을 구할 것입니다 – Kyslik

+0

이 명령은 내 API 경로를 보이지 않습니다. –

+0

@Kyslik'php artisan api : routes' – lagbox

답변

0

답변을 얻었습니다. localhost에서 시도하고있었습니다. API_DOMAIN 및 API_PREFIX에 대한 값을 제공하고있었습니다. 그러나이 경우 API_DOMAIN이 필요하지 않음을 알아야합니다.