phpzend-frameworkzend-applicationzend-framework-moduleszend-config

Module specific resource configuration in application.ini


Can I config a resource to be different when a specific module is used?

From what I have read in the documentation (example #12) this should be possible. But I have had no luck with it yet.

In detail, I'm trying to set another path for translation files.

resources.translate.adapter = "array"
resources.translate.data = APPLICATION_PATH "/views/languages"
resources.translate.options.scan = "filename"
resources.translate.options.disableNotices = true
resources.translate.options.logUntranslated = false 
mobile.resources.translate.data = APPLICATION_PATH "/modules/mobile/views/languages"

From the docs

Example #12 Configuring Modules

You can specify module-specific configuration using the module name as a prefix or sub->section in your configuration file.

For example, let's assume that your application has a "news" module. The following are INI >and XML examples showing configuration of resources in that module.

  1. [production]
  2. news.resources.db.adapter = "pdo_mysql"
  3. news.resources.db.params.host = "localhost"
  4. news.resources.db.params.username = "webuser"
  5. news.resources.db.params.password = "XXXXXXX"
  6. news.resources.db.params.dbname = "news"

Solution

  • I was missing a module Bootstrap file.

    Added /modules/mobile/Bootstrap.php

    <?php
    
    class Mobile_Bootstrap extends Zend_Application_Module_Bootstrap {
    }
    

    Now things work, and the per module translation also (mentioned in comments on initial post).