View Source

<ac:macro ac:name="note"><ac:parameter ac:name="title">Under Construction</ac:parameter><ac:rich-text-body>
<p>This proposal is under construction and is not ready for review.</p></ac:rich-text-body></ac:macro>

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

{zone-data:component-name}
Zend_Controller_RewriteRouter
{zone-data}

{zone-data:proposer-list}
Michael Minicki aka Martel Valgoerad
{zone-data}

{zone-data:revision}
1.1 - 1 August 2006: Updated from community comments.
{zone-data}

{zone-data:overview}
Zend_Controller_RewriteRouter allows for native PHP URL rewriting. It allows a usage of self created and controlled url schemes.
{zone-data}

{zone-data:references}
* Zend_Controller_RewriteRouter was inspired by Ruby routing:
http://manuals.rubyonrails.com/read/chapter/65

The route interface was inspired by very early sketch of skeleton framework created on sitepoint forums (yet the code was written from scratch for my own project sometime ago): http://ap3.sourceforge.net/ (skeleton classes)

I don't recognize a single line of code though ;)
{zone-data}

{zone-data:requirements}
No requirements at this point.
{zone-data}

{zone-data:dependencies}
* Zend_Controller_Router
* Zend_Controller_Dispatcher
* Zend_Controller_Dispatcher_Token
{zone-data}

{zone-data:operation}
Thanks to this component user can use self created URL schemes.

* Routes are matched in reversed order.
* Allows for setting named parameters
* Allows for setting defaults
* Allows for setting requirement masks
* Uses default if the url param value is not in a proper mask
{zone-data}

{zone-data:class-list}
* Zend_Controller_RewriteRouter
* Zend_Controller_Router_Route
{zone-data}

{zone-data:use-cases}
{code}
Zend::loadClass('Zend_Controller_RewriteRouter');
$router = new Zend_Controller_RewriteRouter();

// Example URL: http://domain.com/archive/2005
// Controller: ArchiveController
// Action: showAction

$router->addRoute('archive/:year', array('year' => 2006, 'controller' =>
'archive', 'action' => 'show'), array('year' => '\d+'));

// Example URL: http://domain.com/forum/thread/15
// Controller: ForumController
// Action: threadAction
// Param 'id' which can contain digits only

$router->addRoute(':controller/:action/:id', array(), array('id') => '\d+');

// Example URL: http://domain.com/forum/thread/15
// Controller: UsersController
// Action: showAction
// Param 'name'

$router->addRoute('authors/:name', array('controller' => 'users',
'action' => 'show'));

Zend::loadClass('Zend_Controller_Front');
$ctrl = Zend_Controller_Front::getInstance();
$ctrl->setRouter($router);

Zend_Controller_Front::run(BASE_DIR . 'webapp/controllers')
{code}

{zone-data}

{zone-data:skeletons}
{code}
Zend_Controller_RewriteRouter:
public function addRoute($map, $params = array(), $reqs = array());
public function route(Zend_Controller_Dispatcher_Interface $dispatcher);

Zend_Controller_Router_Route:
public function __construct($route, $defaults = array(), $reqs = array());
public function match($path);
{code}
{zone-data:milestones}
No milestones defined yet
{zone-data}

{zone-template-instance}]]></ac:plain-text-body></ac:macro>