경로 바인딩 방법
컨트롤러/액션에 바인딩
현재 URL을 컨트롤러/액션에 바인딩합니다. 예를 들어 경로 정의 파일에 추가하면
// 绑定当前的URL到 Blog控制器 Route::bind('blog'); // 绑定当前的URL到 Blog控制器的read操作 Route::bind('blog/read');
입니다. 라우팅 컨트롤러/작업에 유효합니다. 블로그 컨트롤러에 바인딩하면 원래 액세스 URL은
http://serverName/blog/read/id/5
에서
http://serverName/read/id/5
로 단순화될 수 있습니다. 경로
Route::get('blog/:id','blog/read');
가 정의되면 액세스 URL은
가 됩니다.http://serverName/5
bound 네임스페이스
로 설정 현재 URL을 지정된 네임스페이스에 바인딩합니다. 예:
// 绑定命名空间 Route::bind(':\app\index\controller');
그런 다음
http://serverName/blog/read/id/5
를 통해 appindexcontrollerBlog 클래스의 읽기 메서드에만 직접 액세스하면 됩니다.
클래스에 바인딩
현재 URL을 지정된 클래스에 직접 바인딩합니다. 예:
// 绑定到类 Route::bind('\app\index\controller\Blog');
그런 다음
http://serverName/read/id/5
를 통해 appindexcontrollerBlog 클래스의 읽기 메서드에 직접 액세스하기만 하면 됩니다.