mardi 24 janvier 2017

Mapping multiple routes (controller) using a router

I am looking at danny vankooten router library here. This looks good (though not sure how will it handle project from medium to large, example an ecommerce site). Now, going by the example this is mapping

$router->map('GET','/', 'home.php', 'home');
$router->map('GET','/home/', 'home.php', 'home-home');
$router->map('GET','/plans/', 'plans.php', 'plans');
$router->map('GET','/about/', 'about.php', 'about');
$router->map('GET','/contact/', 'contact.php', 'contact');
$router->map('GET','/tos/', 'tos.html', 'tos');

Let say I have a scenario where my website has 20-30 static pages or near about 50 controllers with 2-3 action/method each.

How do I map them all. If I use the above method of mapping I will probably end up having more than 100 lines of mapping and this does not looks right.

I believe there should be a way or short cuts/wildcard like check if there is a page or controller available,then load it or else throw a 404.

How do I map all the routes the right way?.

Aucun commentaire:

Enregistrer un commentaire