2013-06-22 4 views
0

안녕하세요 저는 laravel 프레임 워크에 익숙하지 않아 컨트롤러에서 특정 메서드를 호출 할 때 문제가있는 것처럼 보입니다.컨트롤러 메서드 호출

여기까지 제가 한 것입니다.

내가 컨트롤러 경로 구성한 :

http://localhost:8585/RestPHP/public/users/get_index 
http://localhost:8585/RestPHP/public/users/get_index 

:

Route::controller('users', 'UserController'); 

class UserController extends BaseController{ 

public $restful = true; 

public function get_index($id = null) 
{ 
    $ceva = new Model(); 
    return Response::json($ceva); 
} 

public function get_index2() 
{ 
    return "something"; 
} 

}

ASP.NET MVC I의 배경으로부터 오는 것은 이런 각각의 메소드를 호출하는 것으로 그러나 예외가 발견되지 않는 컨트롤러 메소드가 발생합니다.

그 자체로 get_index 메서드를 얻는 방법을 알고있는 것처럼 보입니다.

나는 호출하는 경우 :

http://localhost:8585/RestPHP/public/users/

는 내가 필요로하는

가 어떻게 각각의 방법을 호출 할 수 있습니다 내 json으로 repsonse를 얻을?

+0

Laravel 3 - Restful Controllers (Restful Controllers) (https://tutsplus.com/lesson/restful-controllers/)의 편안한 컨트롤러에 대해이 강의를 시청할 것을 권합니다. @JeffreyWay – Altrim

답변

4

당신은 Laravel 3 또는 4에서 일하고 있습니까?

메서드 이름은 동사 + URI를 정의합니다. 따라서 get_index의 경우 URL은 단순히 /index ... /get_index이 아닙니다.

v4를 사용하는 경우 대신 풍부한 컨트롤러를 사용하는 것이 좋습니다.

관련 문제