Overview Edit

What is URL Routing? Edit

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 Edit

In Agavi, filenames are important because the framework maps blah blah blah.

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

   <route name="routing" pattern="^/routing" module="Routing">
       <route name=".gateways" pattern="^/gateways" action="Gateways">
           <route name=".edit" pattern="^/edit/(id:\d+)(/)?$" action=".Edit" />
           <route name=".show" pattern="^(/)?$" action=".Show" />

This means that:

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.

Misc Edit

How to Generate a URL from a route Edit


class MyView extends MyProjectBaseView
    public function executeHtml(AgaviRequestDataHolder $rd)
        $url = $this->getContext()->getRouting()->gen('routing.gateways.edit');
         * $url now contains
         * The ID, 123, has been automatically added.

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