1 <?xml version="1.0" encoding="UTF-8"?>
3 <sect3 id="zend.controller.router.routes.static">
4 <title>Zend_Controller_Router_Route_Static</title>
7 The examples above all use dynamic routes -- routes that contain
8 patterns to match against. Sometimes, however, a particular route is
9 set in stone, and firing up the regular expression engine would be
10 an overkill. The answer to this situation is to use static routes:
13 <programlisting language="php"><![CDATA[
14 $route = new Zend_Controller_Router_Route_Static(
16 array('controller' => 'auth', 'action' => 'login')
18 $router->addRoute('login', $route);
22 Above route will match a <acronym>URL</acronym> of
23 <filename>http://domain.com/login</filename>, and dispatch to
24 <methodname>AuthController::loginAction()</methodname>.
27 <note id="zend.controller.router.routes.static.warning">
28 <title>Warning: Static Routes must Contain Sane Defaults</title>
31 Since a static route does not pass any part of the <acronym>URL</acronym> to the
32 request object as parameters, you <emphasis>must</emphasis> pass
33 all parameters necessary for dispatching a request as defaults to
34 the route. Omitting the "controller" or "action" default values will
35 have unexpected results, and will likely result in the request being
40 As a rule of thumb, always provide each of the following default
45 <listitem><para>controller</para></listitem>
46 <listitem><para>action</para></listitem>
47 <listitem><para>module (if not default)</para></listitem>
51 Optionally, you can also pass the "useDefaultControllerAlways"
52 parameter to the front controller during bootstrapping:
55 <programlisting language="php"><![CDATA[
56 $front->setParam('useDefaultControllerAlways', true);
60 However, this is considered a workaround; it is always better to
61 explicitly define sane defaults.