Question

I'm at the start of a build of a relatively large site using Zend Framework. I'm thinking of using modules, and folder's in each module controller folder to organise the application controllers.

My question really is, what's the best way to create, manage and maintain routes for applications where every request requires a defined route?

To the best of my knowledge, the options are:

  1. Include all route definitions in application.ini
  2. Include all route definitions in a bootstrap.php _initRoutes method
  3. Autoload from bootstrap.php a resource that compiles and adds the routes from a seperately stored routes.xml file

This application will include a core 'site' that is extended by seperate modules to in essence deliver a multi-site application.

This is an example of my proposed application structure:

|Project
    |-Application
        |-api
        |-configs
        |-controllers
        |-models
        |-modules
            |-core
                |-controllers
                    |-Products
                        |-blueController.php
                        |-redController.php
                        |-greenController
                    |-Services
                        |-indoorController.php
                        |-outdoorController.php
                |-models
                |-views
                |-Bootstrap.php
            |-site1
            |-site2
            |-site3
        |-views
        |-Bootstrap.php
    |-Docs
    |-Library
    |-Public
    |-.zfproject.xml

No correct solution

OTHER TIPS

In the spirit of modularity I think it best for each module to take responsibility for it's own routing info in it's bootstrap file.

protected function _initRoutes()
{
    $routes = array(
        ....
    );
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $router->addConfig(new Zend_Config($routes), 'mymodulename');
    return $router;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top