Agavi - Routing

What is URL Routing?
Lorem ipsum dolor sit amet consectutor adipsing elit. Blah blah blah, centralizes common code and logic blah blah blah boring theoretical stuff about front controller pattern blah blah blah blah.

URL Routing enables us to easily design our Web applications using the REST Architecture.

It also gives us additional security because the URL is restricted by the regular expression set in the configuration file.

File System Naming Convention
In Agavi, filenames are important because the framework maps blah blah blah.

In this example, we'll use the following URL route:

   

This means that:
 * Requests sent to http://example.org/routing will be sent to the Routing module, which is located at %project_dir%/app/modules/Routing
 * Requests sent to http://example.org/routing/gateways will be sent to the "Show" action, which is located at %project_dir%/app/modules/Routing/actions/Gateways/ShowAction.class.php.
 * Requests sent to http://example.org/routing/gateways/edit/123 will be sent to the "Edit" action, which is located at %project_dir%/app/modules/Routing/actions/Gateways/EditAction.class.php.

As mentioned earlier, filenames are important. Agavi uses the route names to (1) determine the class names and (2) determine where to look for the classes. Thus, for the Show action, the class is named Routing_Gateways_ShowAction. Notice the pattern in the paths as well.

How to Generate a URL from a route
getContext->getRouting->gen('routing.gateways.edit'); /**        * $url now contains http://example.org/routing/gateways/edit/123. * The ID, 123, has been automatically added. */

$this->setAttribute('this_url', $url); } } ?>