compared with
Current by Ben Scholzen
on Jan 29, 2010 07:51.

(show comment)
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (58)

View Page History
h1. Zend_Controller_Router 2.0 RoadMap
<h1>Zend_Controller_Router 2.0 RoadMap</h1>

{toc-zone:type=list|minLevel=2|maxLevel=3|location=top}
<ac:macro ac:name="toc-zone"><ac:parameter ac:name="type">list</ac:parameter><ac:parameter ac:name="minLevel">2</ac:parameter><ac:parameter ac:name="maxLevel">3</ac:parameter><ac:parameter ac:name="location">top</ac:parameter></ac:macro>

h2. Refactoring of Zend_Controller_Router_Rewrite
<h2>Refactoring of Zend_Controller_Router_Rewrite</h2>

h3. Goal
<h3>Goal</h3>

<p>The current layout of the router and it's routes is not very flexible and was not made for the problems it currently tries to solve. Thus, it is going under refactoring to solve the drawbacks. In general, the following topics should be covered with the new router:</p>

<ul>
* Lightweight: <li>Lightweight: Should be as fast or if possible even faster than the current implementation</li>
* Design <li>Design by contract: The router and its routes get covered by interfaces</li>
* The <li>The router should completly work with the request object instead of URL-strings</li>
* Fixing <li>Fixing bugs which are hard to fix without a BC-break</li>
</ul>

h3. Routes

Routes are something which are independent to the rewrite router, and thus can be interfaced completly for this purpose:
<h3>Routes</h3>

* The getInstance() method will be removed from all routes. Instead we will use a unified constructor
* getDefault() and getDefaults() will become interface methods
* The match() method will only allow an instance of Zend\Controller\Request\Http
<p>Routes are something which are independent to the rewrite router, and thus can be interfaced completly for this purpose:</p>

h4. Building routes via config
<ul>
<li>The getInstance() method will be removed from all routes. Instead we will use a unified constructor</li>
<li>getDefault() and getDefaults() will become interface methods</li>
<li>The match() method will only allow an instance of Zend\Controller\Request\Http</li>
</ul>

The router will allow to not only give complete class names for the route types, but also just the actual route name (module, regex, chain, etc.). This allows for much less typing-work. The router will also accept arrays as configuration now instead of just Zend_Config instances (see unified constructors).

h4. Chaining
<h4>Building routes via config</h4>

The currently known chaining will be dropped in favor of tree-matching. This will be setup similar to route chaining, but allow to match a segment in the tree only once, which will lead to better performance. For instance the router will only have to check for the hostname only once, instead of the current approach matching it for every single route again and again.
<p>The router will allow to not only give complete class names for the route types, but also just the actual route name (module, regex, chain, etc.). This allows for much less typing-work. The router will also accept arrays as configuration now instead of just Zend_Config instances (see unified constructors).</p>

h4. Hostname route
<h4>Chaining</h4>

The hostname route will get an additional parameter, which will allow to enforce https connections. If activated, the route will only match when the connections comes via HTTPS, and assembling will prefix https:// instead of http://.
<p>The currently known chaining will be dropped in favor of tree-matching. This will be setup similar to route chaining, but allow to match a segment in the tree only once, which will lead to better performance. For instance the router will only have to check for the hostname only once, instead of the current approach matching it for every single route again and again.</p>

h3. Caching support
<h4>Hostname route</h4>

The new rewrite router system will also come with caching support. This will be supported by creating a unique key out of the HTTP request object and storing the matched result. By doing this, a specific route will only have to be matched once. This allows future matching of the same route without iterating through all defined routes.
<p>The hostname route will get an additional parameter, which will allow to enforce https connections. If activated, the route will only match when the connections comes via HTTPS, and assembling will prefix https:// instead of http://.</p>

h3. Interfaces
<h3>Caching support</h3>

* Zend\Controller\Router\RouterInterface
* Zend\Controller\Router\Rewrite\RouteInterface
<p>The new rewrite router system will also come with caching support. This will be supported by creating a unique key out of the HTTP request object and storing the matched result. By doing this, a specific route will only have to be matched once. This allows future matching of the same route without iterating through all defined routes. </p>

h3. Abstract
<h3>Interfaces</h3>

* Zend\Controller\Router\RouterAbstract
<ul>
<li>Zend\Controller\Router\RouterInterface</li>
<li>Zend\Controller\Router\Rewrite\RouteInterface</li>
</ul>

h3. Classes

* Zend\Controller\Router\Rewrite\Router
* Zend\Controller\Router\Rewrite\Route\Module
* Zend\Controller\Router\Rewrite\Route\Segment
* Zend\Controller\Router\Rewrite\Route\Chain
* Zend\Controller\Router\Rewrite\Route\Regex
<h3>Abstract</h3>

h3. CS-Cleanup
<ul>
<li>Zend\Controller\Router\RouterAbstract</li>
</ul>

Currently the router doesn't follow the coding standard completly, this will be solved together with the refactoring.

h3. Prototype
<h3>Classes</h3>

There is also a protoype unter development. Currently there's not much to see, but it will evolve in the near future:
<ul>
<li>Zend\Controller\Router\Rewrite\Router</li>
<li>Zend\Controller\Router\Rewrite\Route\Module</li>
<li>Zend\Controller\Router\Rewrite\Route\Segment</li>
<li>Zend\Controller\Router\Rewrite\Route\Chain</li>
<li>Zend\Controller\Router\Rewrite\Route\Regex</li>
</ul>

http://framework.zend.com/svn/framework/standard/branches/user/dasprid/Zend_Controller_Router-2.0/

h2. [Open JIRA Issues|http://framework.zend.com/issues/secure/IssueNavigator.jspa?reset=true&jqlQuery=project+%3D+ZF+AND+%28summary+~+router+OR+description+~+router%29+AND+resolution+%3D+Unresolved+AND+fixVersion+%3D+EMPTY+AND+component+%3D+Zend_Controller+ORDER+BY+priority+DESC]
<h3>CS-Cleanup</h3>

{jiraissues:columns=key;type;priority;summary;created;updated|url=http://framework.zend.com/issues/secure/IssueNavigator.jspa?view=rss&jqlQuery=project+%3D+ZF+AND+%28summary+~+router+OR+description+~+router%29+AND+resolution+%3D+Unresolved+AND+fixVersion+%3D+EMPTY+AND+component+%3D+Zend_Controller+ORDER+BY+priority+DESC&tempMax=1000|cache=off}
<p>Currently the router doesn't follow the coding standard completly, this will be solved together with the refactoring.</p>

<h3>Prototype</h3>

<p>There is also a protoype unter development. Currently there's not much to see, but it will evolve in the near future:</p>

<p><a class="external-link" href="http://framework.zend.com/svn/framework/standard/branches/user/dasprid/Zend_Controller_Router-2.0/">http://framework.zend.com/svn/framework/standard/branches/user/dasprid/Zend_Controller_Router-2.0/</a></p>

<h2><a href="http://framework.zend.com/issues/secure/IssueNavigator.jspa?reset=true&amp;jqlQuery=project+%3D+ZF+AND+%28summary+~+router+OR+description+~+router%29+AND+resolution+%3D+Unresolved+AND+fixVersion+%3D+EMPTY+AND+component+%3D+Zend_Controller+ORDER+BY+priority+DESC">Open JIRA Issues</a></h2>

<ac:macro ac:name="jiraissues"><ac:parameter ac:name="columns">key;type;priority;summary;created;updated</ac:parameter><ac:parameter ac:name="url">http://framework.zend.com/issues/secure/IssueNavigator.jspa?view=rss&amp;jqlQuery=project+%3D+ZF+AND+%28summary+~+router+OR+description+~+router%29+AND+resolution+%3D+Unresolved+AND+fixVersion+%3D+EMPTY+AND+component+%3D+Zend_Controller+ORDER+BY+priority+DESC&amp;tempMax=1000</ac:parameter><ac:parameter ac:name="cache">off</ac:parameter></ac:macro>