Zend Framework modular design


Hi

This is a repost of the old post about the zend framework modular redesign .

Files and directories hierearchy

www/
 application/
  admin/
   controllers/
   forms/
   layouts/
   models/
   views/
  configs/
   application.ini
  default/
   controllers/
   forms/
   layouts/
   models/
   views/
  Bootrstap.php
 library/
  Zend/
 public/
  index.php

And here is the configs/application.ini file , I will list the most important lines .
This is for the modules , note that we have made the module directory , the Application Path itself , so you can put your modules inside application directory as we did in the directories hierarchy .

includePaths.library = APPLICATION_PATH "/../library"

bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

appnamespace = "Application"
resources.frontController.moduleDirectory = APPLICATION_PATH 
resources.modules[] = 


and in the Bootstrap file , you can define _init function as you can , the most important one is the autoload function , here is Bootstrap.php file
here you are loading the two namespace you have ( default and admin ) .

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap {

    public function _initAutoload() {
        $autoloader = new Zend_Application_Module_Autoloader(
                        array('namespace' => 'Default',
                            'basePath' => dirname(__FILE__) . '/default',
                        )
        );
        
        $autoloader2 = new Zend_Application_Module_Autoloader(
                        array('namespace' => 'Admin',
                            'basePath' => dirname(__FILE__) . '/admin',
                        )
        );
        
        $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
        Zend_Layout::startMvc();
        $bootstrap = $application->getBootstrap();

        Zend_Session::start();
        $db = new Zend_Db_Adapter_Mysqli($bootstrap->getOption("database"));
        Zend_Db_Table_Abstract::setDefaultAdapter($db);
        return $autoloader;
    }
}
That's it , feel free to ask any questions .