Ok, Simon, thanks for writing up a tutorial for us in a month or so.
Basically I was just asking for a simple way of using a modular directory 
structure at the current development status of ZF. (I can't wait a month or so, 
you know.)
As it is already supported but just not well documented (shout at me RTFM! if 
I'm wrong), I figured it out by myself, digging around in 
Zend_Controller_Dispatcher_Interface::_getController() and 
Zend_Controller_Request_Abstract:
protected $_moduleKey = 'module';

The whole thing is already integrated in Zend_Controller, so all I need to do 
is to set up a route like:

new Zend_Controller_Router_Route(':module/:controller/:action/*', 
array('module' => 'index', 'controller' => 'index', 'action' => 'index'));

ZF looks now in the following directory for your controller:

/application
    /controllers
        /<module_name>

We could then set up some static routes to make life a bit easier:

new Zend_Controller_Router_StaticRoute('logout', array('action' => 'logout'));

Instead of calling an ugly "/index/index/logout" URI, we could call "/logout" 
and place the logout action directly in 
/application/controllers/IndexController.php
I'd rather prefer some regular expression to write one single static route for 
all requests not matching the :module/:controller/:action layout, something 
like:

new Zend_Controller_Router_StaticRoute('!(admin|moderator)', array('module' => 
'index', 'controller' => 'index', 'action' => '$1'));
(totally wrong regex, I know, this is just pseudocode!!)

If the first URI parameter doesn't match my module names, run the action in the 
index/index controller. Or what about mapping all /action URI's without 
trailing slash to /index/index/action? (we might run into problems here if we 
have enabled UseCanonicalName in our Apache config)
Any idea how to do this without modding any ZF classes?

Cheers,
Philip



Simon R Jones wrote:
> We're basically extending bits of ZF to provide this functionality. A bit
> like the Zend_App class that I seem to recall being mentioned on this list
> in the past. 
> 
> It's a bit difficult to go into lots of detail at present since we're in the
> middle of this project and it has another month of development left. But I
> can write up a tutorial on the useful points once we're done if it would be
> helpful. 
> 
> best wishes,
> Si
> 

Reply via email to