King23 routes…

I just made a pretty small change in the way King23 works with its routing,
while it is fully backward compatible, it now allows you to add sub-routers to organise your routes a bit. So you dont end up having a list of thousand routes below eachother (and executionwise it means less iterations, more speed, if you use subrouters, instead of declaring all routes in a flat list).

It also allows you fancy stuff like extending the router class, overloading the usual router methods by own implementations that only run for a specific subroute… use your imagination of what you can do with this =)

A very simple usage example:

<?php
// get instace of the mainrouter
$router = King23_Router::getInstance();

// get a non singleton instance of King23_Router
$subrouter = new King23_Router();

// declare a few routes at the subrouter
$subrouter->addRoute("one/",  "My_View",  "one", array("param1", "param2"));
$subrouter->addRoute("two/",  "My_View",  "two", array("param1", "param2"));
$subrouter->addRoute("/", "My_View", "index");

// add the subrouter with a route to the main router
$router->addRouter("/projects/", $projects);

// add regular routes to the main router
$router->addRoute("/",          "Devedge_Static_View",  "index",    array());

One more thing, this is currently only available in git, not in any release yet.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s