Using Route objects, these two operations can be handled in a reciprocally consistent way.
For example, if you wanted the /login URL to be routed to
myapp\controllers\SessionsController::add(), you could set up a route like the following in
config/routes.php:
{{{
use lithium\net\http\Router;
Router::connect('/login', array('controller' => 'Sessions', 'action' => 'add'));
-- or --
Router::connect('/login', 'Sessions::add');
}}}
Not only would that correctly route all requests for /login to SessionsController::add(), but
any time the framework generated a route with matching parameters, Router would return the
correct short URL.
While most framework components that work with URLs (and utilize routing) handle calling the
Router directly (i.e. controllers doing redirects, or helpers generating links), if you have a
scenario where you need to call the Router directly, you can use the match() method.
This allows you to keep your application's URL structure nicely decoupled from the underlying
software design. For more information on parsing and generating URLs, see the parse() and
match() methods.