Zend(v1)Autoloader不起作用

时间:2014-04-19 19:27:24

标签: php zend-framework ini bootstrapping zend-autoloader

我现在有点迷失了。我尝试建立自己的库,但自动加载器似乎没有以某种方式工作。 这exaple这是我发现的最接近的,但所有解决方案都不适用于我。

这是我的文件夹结构。

-application
 |_modules
  |_vita
   |_controllers
    |_IndexController.php
-data
-docs
-library
 |_ND
 ||_Model
 | |_Vita
 |  |_Vita.php
 |_Zend
-public
-tests

这是我的引导程序。

class Bootstrap extends Zend_Application_Bootstrap_Bootstrap 
{    
    ...

    protected function _initAutoloader()
    {
        $loader = Zend_Loader_Autoloader::getInstance();
        $loader->registerNamespace('ND_');
        return $loader;
    }

    ...
}

这是我的完整application.ini(我知道autoloaderNamespaces指令与引导程序中的指令是双重的,但是不能同时使用每个 强>)

[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path       = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class      = "Bootstrap"
appnamespace         = "Application"

; automatic loading of libraries 
autoloaderNamespaces[] = "ND_"

phpSettings.date.timezone = "Europe/Berlin"

;resources.frontController.controllerDirectory = APPLICATION_PATH "/modules/index/controllers"
;resources.frontController.params.displayExceptions = 0

;appnamespace = "Application"
resources.frontController.moduleDirectory            = APPLICATION_PATH "/modules"
resources.frontController.params.prefixDefaultModule = true
resources.frontController.defaultModule              = "index"
resources.frontController.throwerrors                = false
resources.frontController.params.displayExceptions   = 0

; resources (modules)
resources.modules[] = ""
resources.view[]    = ""


; resources (layout)
resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts"
resources.layout.layout     = "main"

; db settings
resources.db.adapter           = "PDO_MYSQL"
resources.db.isDefaultAdapter  = true
resources.db.params.host       = "localhost"
resources.db.params.username   = "root"
resources.db.params.password   = ""
resources.db.params.dbname     = "nd"

[staging : production]

[testing : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1

[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
resources.frontController.params.displayExceptions = 1

这是我的控制器,我试图实例化这个类" Vita" 但我总是收到此错误:"致命错误:类' ND_Model_Vita_Vita'在第17行和第34行的C:\ xampp \ htdocs \ ND \ application \ modules \ vita \ controllers \ IndexController.php中找不到;

class Vita_IndexController extends Zend_Controller_Action
{
    public function init()
    {
        $this->view->headTitle('Vita');
    }

    public function indexAction()
    {
        /* Just to try if the Loader is working for the Zend library -> it works */
        $this->newForm = new Zend_Form();


        $this->mdlVita = new ND_Model_Vita_Vita();
        Zend_Registry::get('log')->info($this->mdlVita->test());
    }
}

这就是Vita Class

class ND_Model_Vita_Vita
{
    public function test()
    {
        return 'Is working';
    }
}

在使用模块时,是否有一些我可能忽略的东西或者我必须要记住的东西? 我很感激任何建议。

编辑:我将问题缩小到与xampp环境有关。我将项目推送到实时apache位置并在那里工作

0 个答案:

没有答案