【问题标题】:zend auto loader... custom classes. How do I get it to work?zend 自动加载器...自定义类。我如何让它工作?
【发布时间】:2012-10-05 14:14:29
【问题描述】:

我希望在 library/common 文件夹中创建自己的类文件集合

/library/common/*class files go in here*

在该文件夹中,我将有各种我想要提供的类文件

比如

DecoratorSimple.php

代码示例如下?

class Common_Decorator_SimpleInput extends Zend_Form_Decorator_Abstract
{
  // code goes in here
}

我的问题是如何让 zend 应用程序自动加载具有 Common_ 前缀的公共文件夹中的任何内容

我尝试在引导程序中添加以下内容,但没有成功

protected function _initTestAutoLoader(){

    $autoloader = Zend_Loader_Autoloader::getInstance();
    $autoloader->registerNamespace('Common_');

    // try and load the class
    $testVar = new Common_Decorator_SimpleInput();
    var_dump($test);
}

【问题讨论】:

  • 您遇到的错误是什么?另外,我认为问题在于您没有在include_path中注册/Library/

标签: php zend-framework zend-autoloader


【解决方案1】:

您的类名是否与库路径匹配...
例如 Common_Decorator_SimpleInput
必须在 /library/Common/Decorator/SimpleInput.php

【讨论】:

  • 原来是这样。对于每个“_”(分隔符),我需要添加一个额外的文件夹。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-09-28
  • 1970-01-01
  • 2013-10-25
  • 1970-01-01
  • 2013-08-30
  • 1970-01-01
相关资源
最近更新 更多