Zend Framework Modules can't find/load Models

后端 未结 4 1633
北恋
北恋 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 05:51

    What just fixed it for me was to add the following line to application.ini

    resources.modules[]=

    Then i added a Bootstrap.php to the module directory ('application\modules\books\')

    class Books_Bootstrap extends Zend_Application_Module_Bootstrap {
    
        protected function _initAutoload()
        {
          $autoloader = new Zend_Application_Module_Autoloader(array(
               'namespace' => 'Books_',
               'basePath' => dirname(__FILE__)
          ));
          return $autoloader;
         }
    }    
    

    Move the books model to 'application\modules\books\models\Books.php'

    class Books_Model_Books extends Zend_Db_Table_Abstract {...}
    

    Now you should be able to load the model in the IndexController

    $model = new Books_Model_Books();
    

提交回复
热议问题