开发者

Module autoloader problem in zf

i have 3 moulde like blow ,

 application
        |
        modules
           |
           default
             |---models
             |--views
             |--forms
             |--controller-
                           |-indexController
                           |-errorController
          admin
             |---models-
                        |-user.php
             |--views
             |--forms
             |--controller--
                            |-userController
          cars
             |---models
             |--views
             |--forms
             |--controller

    bootstrap.php

and in my appliction.ini

i have this config

resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.modules = ""

and in my bootsrap file i have this autoloader

$modelLoader = new Zend_Application_Module_Autoloader(array(
            开发者_开发知识库        'namespace' => '',
                    'basePath' => APPLICATION_PATH ));

so i can not access to my models class in userController and other controllers

i have this code in my userController

$userModel = new admin_Model_Users();

but i got error can not find this class

and this class is in user.php

class admin_Model_Users extends Zend_Db_Table_Abstract
{


 public function getListUser() {


    }
}

someone may help where is my wrong and how could fix this problem?


Get rid of

 $modelLoader = new
 Zend_Application_Module_Autoloader(array(
                     'namespace' => '',
                     'basePath' => APPLICATION_PATH ));

and add Bootstrap.php in you module:

class Admin_Bootstrap extends Zend_Application_Module_Bootstrap
{

}

also name your class Admin_Model_Users and use it accordigly where appropriorate. Use capital "U" in the filename, capital "A" in the class name. I mean names should be consistent and in accordance to ZF guidelines.

Also in ini file: change entry to

resources.modules[] =


Try the following:

class admin_Model_Users extends Zend_Db_Table_Abstract

Should become

class Models_UsersAdmin extends Zend_Db_Table_Abstract


$userModel = new admin_Model_Users();

Should become

$userModel = new Models_UsersAdmin();


Update

in you're application.ini file where you register you're namespaces add the following line: autoloaderNamespaces[] = "Models" ( or register the namespace "Models" at bootstrap )


;define modules after controller in application.ini file
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜