Zend Framework Modules can't find/load Models

后端 未结 4 1630
北恋
北恋 2021-02-11 05:12

For some frustrating reason, I configured some Modules, which seemed to work fine, However I cannot load a Modules Models. If I move the Models to the Default they load, but I j

4条回答
  •  我在风中等你
    2021-02-11 06:13

    In the application.ini, add a simple line:

    resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
    

    and in the method _initAutoload() inside the Bootstrap put:

    $front = $this->bootstrap("frontController")->frontController;
    $modules = $front->getControllerDirectory();
    $default = $front->getDefaultModule();
    
    foreach (array_keys($modules) as $module) {
        if ($module === $default) {
            continue;
        }
    
        $moduleloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => $module,
            'basePath'  => $front->getModuleDirectory($module)));
    }
    

    make sure the name of models inside each module are like

    [name_module]_Model_[name_model]
    

    in you case, like

    class Books_Model_Books {
    }
    

    and that's all :D

提交回复
热议问题