Hey guys, I've been toying with ZF2 lately and hit some configuration issues.
Say i have a website with a frontend and a backend. I see these naturally mapping each to a module, and each module having it's specific routes. The module.config.php files for each module contains settings for the ViewManager (they each define a template_map, a layout, an exception_template, etc.). What i've noticed is that even if these are different for each module, they are in fact merged into one single config which is then passed to the ViewManager. Looking into the code a little deeper it started to make sense: module configs are used for bootstrapping, and there is no correlation between the module bootstrapping and route bootstrapping (because what i actually want is per route configuration). Searching for solution to this, i found a layout related solution here: http://blog.evan.pro/module-specific-layouts-in-zend-framework-2 and here: https://github.com/EvanDotPro/EdpModuleLayouts What Evan does there in two different ways is to listen to the dispatch event, and apply the custom config in the event listener. Going further, i can easily imagine an implementation that can extend this approach and allow for defining 'true' per module configuration. Example: (in module.config.php) 'module_name_here' => array( 'view_manager' => array( 'template_map' => array( 'layout/layout' => __DIR__ . '/../view/layout/layout.phtml' ) ... ) ); (by adding this to Evan's github code) if ( isset( $config[strtolower( $moduleNamespace )]['view_manager']['template_map'] ) ) { $e->getApplication() ->getServiceManager() ->get( 'viewtemplatemapresolver' ) ->merge( $config[strtolower( $moduleNamespace )]['view_manager']['template_map'] ); } So one could define a whole new config namespaced under the module name, but applying this config requires code which has most likely already been written to apply the main merged config (on the boostrap event). So how about a feature to support this module namespacing to config, in order to avoid having your module config overwritten by another module. Now i also have the feeling that i got this whole thing wrong. That the modules in ZF2 are completely different in intent and usage from the ones in ZF1 and my mind just didn't adjust yet to the new approach, and is trying to apply old techniques to the new framework. If this is the case, please make an attempt at explaining the correct way of thinking and implementing a basic website with a frontend and a backend, each having one single route (so /controller/action for frontend and /backend/controller/action for backend) with a different config for each route (different in default tempaltes, layout, doctypes ... pretty much different in everything view related). Thanks, Alex -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/ZF2-per-route-or-module-configuration-tp4656844.html Sent from the Zend Framework mailing list archive at Nabble.com. -- List: [email protected] Info: http://framework.zend.com/archives Unsubscribe: [email protected]
