
Yaf_Router::route() 메서드를 사용하여 라우팅 설정을 동적으로 할 수 있습니다.
#hostingforum.kr
php
$routes = array(
'home' => 'Index/index',
'about' => 'About/about',
'contact' => 'Contact/contact',
);
$router->addRoutes($routes);
이 방법은 라우팅 설정을 배열로 정의하고, Yaf_Router::addRoutes() 메서드를 사용하여 라우팅 설정을 동적으로 추가할 수 있습니다.
또한, 라우팅 설정을 JSON 파일이나 데이터베이스에서 읽어와서 동적으로 추가할 수도 있습니다.
#hostingforum.kr
php
$routes = json_decode(file_get_contents('routes.json'), true);
$router->addRoutes($routes);
또는
#hostingforum.kr
php
$routes = array();
$result = $db->query('SELECT * FROM routes');
while ($row = $result->fetchArray()) {
$routes[$row['name']] = $row['route'];
}
$router->addRoutes($routes);
이러한 방법으로 라우팅 설정을 동적으로 할 수 있습니다.
2025-07-05 04:26