
Yaf_Router::__construct에서 'route' 인자는 라우팅 설정을 위한 배열입니다. 라우터를 생성할 때 필요한 인자는 다음과 같습니다.
- $config: 라우팅 설정을 위한 배열
- $defaultModule: 기본 모듈 이름
- $defaultController: 기본 컨트롤러 이름
- $defaultAction: 기본 액션 이름
라우터를 생성하여 라우팅 설정을 하는 방법은 다음과 같습니다.
#hostingforum.kr
php
// 라우팅 설정을 위한 배열
$config = array(
'routes' => array(
'home' => array(
'route' => '/home',
'module' => 'home',
'controller' => 'index',
'action' => 'index',
),
'about' => array(
'route' => '/about',
'module' => 'about',
'controller' => 'index',
'action' => 'index',
),
),
);
// 라우터를 생성
$router = new Yaf_Router($config);
// 라우팅 설정
$router->addRoute('home', 'home', 'home', 'index');
$router->addRoute('about', 'about', 'about', 'index');
// 라우팅 설정을 확인
print_r($router->getRoutes());
이러한 방법으로 라우터를 생성하여 라우팅 설정을 할 수 있습니다.
2025-05-21 12:33