또한 CI HMVC에서 3 년 동안 근무했으며 라우팅 예제 중 일부는 거기에 있습니다. 도움이 될 수 있습니다.
저는 여기에서 2 가지 유형의 모듈을 정의합니다. 하나는 사이트이고 다른 하나는 admin입니다. 관리 용
1> 라우팅 : 사이트
/*ADMIN is a constant, you can define anything like admin or backend etc. */
/*Example: admin/login*/
$route[ADMIN.'/([a-zA-Z]+)'] = function($controller){
return 'admin/'.strtolower($controller);
};
/*Example: admin/user/listing*/
$route[ADMIN.'/([a-zA-Z]+)/(:any)'] = function($controller, $function){
return 'admin/'.strtolower($controller).'/'.str_replace("-","_",strtolower($function));
};
/*Example: admin/user/edit/LU1010201352*/
$route[ADMIN.'/([a-zA-Z]+)/(:any)/(:any)'] = function($controller,$function,$param) {
return 'admin/'.strtolower($controller).'/'.str_replace("-","_",strtolower($function)).'/'.$param;
};
/*Example: admin/user/assign-group/LU1010201352/G2010201311*/
$route[ADMIN.'/([a-zA-Z]+)/(:any)/(:any)/(:any)'] = function($controller,$function,$param,$param1){
return 'admin/'.strtolower($controller).'/'.str_replace("-","_",strtolower($function)).'/'.$param.'/'.$param1;
};
2> 라우팅 :
$route['([a-zA-Z]+)'] = function($controller) {
return 'site/'.strtolower($controller);
};
$route['([a-zA-Z]+)/(:any)'] = function($controller,$function){
return 'site/'.strtolower($controller).'/'.str_replace("-","_",strtolower($function));
};
$route['([a-zA-Z]+)/(:any)/(:any)'] = function($controller,$function,$param) {
return 'site/'.strtolower($controller).'/'.str_replace("-","_",strtolower($function)).'/'.$param;
};
$route['([a-zA-Z]+)/(:any)/(:any)/(:any)'] = function($controller,$function,$param,$param1) {
return 'site/'.strtolower($controller).'/'.str_replace("-","_",strtolower($function)).'/'.$param.'/'.$param1;
};
그것은 완전히 동적이다. 모든 모듈 안에 많은 컨트롤러를 만들 수 있습니다. 모듈을 더 추가하려면 1 또는 2와 같은 다른 라우팅 블록을 만듭니다.
안녕하세요 Thrice801이 방법을 찾으셨습니까? – hairynuggets