php - How do I get Zend Framework to use 'module specific' configurations? -


reading section zend_application_resource_modules in docs here: http://framework.zend.com/manual/1.10/en/zend.application.available-resources.html

i noticed this:

you can specify module-specific configuration using module name prefix or sub-section in configuration file.

using this:

  [production]   news.resources.db.adapter = "pdo_mysql"   news.resources.db.params.host = "localhost"   news.resources.db.params.username = "webuser"   news.resources.db.params.password = "xxxxxxx"   news.resources.db.params.dbname = "news" 

to me idea. but, when add these prefixes things want specific modules, nothing changes.

so question is: how tell zend framework use these module specific prefixes?

i use following implementation of modules in zend. allows use "module-specific" configuration.

application/config/config.ini ----------------------------- [production] resources.modules[] = 

by doing this, you're telling zend_application want use modules bootstrap resource plugin. modules plugin load separate bootsrap class each of modules, excluding default module. therefore, need create new bootstrap class second module.

application/modules/news/bootstrap.php ----------------------------- class news_bootstrap extends zend_application_module_bootstrap {     //---------------------------------------    // automatically load our resources    //    // note: don't have add this,    //       , example show    //       can customize bootstrap    //       process module.    public function _initmoduleresourceautoloader(){        $this->getresourceloader()->addresourcetypes(array(          'modelresource' => array(             'path' => 'models/resources',             'namespace' => 'resource'          )       ));    } } 

this "news_bootstrap" class loaded , executed during bootstrap process.

the naming convention file important modules resource plugin needs able find class. note must name file bootstrap.php.

finally, you'll notice you're subclassing zend_application_module_bootstrap rather zend_application_bootstrap_bootstrap in main bootstrap.

now, module-specific configuration should work:

[production] news.resources.db.adapter = "pdo_mysql" news.resources.db.params.host = "localhost" news.resources.db.params.username = "webuser" news.resources.db.params.password = "xxxxxxx" news.resources.db.params.dbname = "news" 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -