Reputation: 41
I used Altorouter in PHP, and I try to dynamic my router. I have an architecture specific with folders, sub-folders, sub-sub-folders.
I have try to do this
//dynamic routage for root main pages
$router->map( 'GET', '/[:pageName]', 'HomeControler::pageRedirect');
//dynamic routage for subfolder pages
$router->map( 'GET', '/[:folder]/[:pageName]', '
HomeControler::subPageRedirect');
That's working, but I just matching with folder / page. I wont doing this method for all sub-folders. How can I detect folders, sub-folders, automatically ?
And In my controller,
I control the folders like that ?
// Dynamic mapping to pages
public static function pageRedirect($pageName) {
self::redirectTo(dirname(__FILE__) . "/../../front/$pageName.php");
}
And I do condition if he doesn't find in this pages ?
Upvotes: 0
Views: 174
Reputation: 4544
You could do
$router->map('GET', '/[*:target]', 'yourController')
This will map any request to your controller. How you interpret target
in your controller is up to you (looking in folders etc.).
Upvotes: 0