2009年2月23日星期一

[fw-mvc] modulear application with router for each controller in each application

I have the following structure for the application

/application
/modules
/admin
/controllers
/indexcontroller.php
/layouts
/site
/controllers
/indexcontroller.php
/layouts
/library

so accessing the index controller of the admin module will be :
example.com/admin and accessing the index controller of the site module will
be just example.com as it set as the default module.

// application/bootstrap.php

defined('APPLICATION_PATH')
or define('APPLICATION_PATH', dirname(__FILE__));

defined('APPLICATION_ENVIRONMENT')
or define('APPLICATION_ENVIRONMENT', 'development');

$frontController = Zend_Controller_Front::getInstance();

$frontController->addModuleDirectory(APPLICATION_PATH . '/modules');

$frontController->setControllerDirectory(array(
'default' => APPLICATION_PATH . '/modules/site/controllers',
'admin' => APPLICATION_PATH . '/modules/admin/controllers',
));

$frontController->setParam('env', APPLICATION_ENVIRONMENT);


Zend_Layout::startMvc($frontController->getModuleDirectory().'/layouts/scripts');

defined('MODULE_PATH')
or define('MODULE_PATH', $frontController->getModuleDirectory() . '/');

$view = Zend_Layout::getMvcInstance()->getView();
$view->doctype('XHTML1_STRICT');

// CLEANUP - remove items from global scope
unset($view);
unset($frontController);


How can i set a rewrite rule class/instance across the entire application
that i could use sub directories inside the main controllers directory for
each module? Meaning so i could have this structure:

/application
/modules
/admin
/controllers
/index
/indexcontroller.php
/othercontroller.php
/tools
/indexcontroller.php
/othercontroller.php
/settings
/indexcontroller.php
/othercontroller.php
/layouts
/site
/controllers
/index
/indexcontroller.php
/othercontroller.php
/tools
/indexcontroller.php
/othercontroller.php
/settings
/indexcontroller.php
/othercontroller.php
/layouts
/library


and i could enter the file admin/controller/tools/other as follows:
admin/tools/other trough the url. and basically use sub directories inside
the controllers directory. what do i need to setup?

Thanks.


--
View this message in context: http://www.nabble.com/modulear-application-with-router-for-each-controller-in-each-application-tp22163221p22163221.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: