Does anyone know how to dynamically install the default module in Zend Framework and not run namespace problems? For example, what I want to do is to have a table of modules that can be loaded, with one of them installed as the default module. For example, I might have:
admin blog calendar
as modules that can be loaded. If I have a โblogโ as the default module, then โadminโ and โcalendarโ should have their own controllers with names (Admin_IndexController, Calendar_IndexController), and โblogโ should not (IndexController).
If I change the calendar to the default module, ZF will no longer be able to find classes due to the namespace.
How do you get around this? I am currently using the following code:
$modules = new Modules(); $activeModules = $modules->fetchActive(); foreach($activeModules as $mod) { $loadedModules[$mod->name] = '..application/modules/' . $mod->name . '/controllers'; if($mod->default) { $defaultModule = $mod->name; } } $frontController->setControllerDirectory($loadedModules); $frontController->setDefaultModule($defaultModule);
php module zend-framework
dragonmantank
source share