Zend框架无法识别类

时间:2014-12-10 06:34:41

标签: php class zend-framework include apigility

当我与Apigility合作时,我对Zend相对较新。
当我尝试从外部文件中包含类(这是另一个MVC项目的一部分)时,会读取文件,但创建实例会返回错误。

如果我使用include / require函数 class_exists 返回true,但仍然无法创建对象,而使用Zend_Loader中的一个自动加载程序会出现错误“class *** not found”(< em> class_exists 在这种情况下返回false)并在屏幕上打印文件的全部内容。

这不是因为我的MVC,因为我遇到了同样的问题,包括即时创建的类。 它不是match problem

有什么想法吗?


编辑 - 因为我试图从名为'Example'的Apigility应用程序的Module.php中的函数getServiceConfig()加载类User

        // Zend\Loader\StandardAutoloader namespace is stated at the beginning and it is working
        $loader = new StandardAutoloader();                 
        $loader->registerPrefix('local', '/home/mylocal/class/local'); 
        $loader->autoload('local_User'); 
        $loader->check = class_exists('User'); // states true and is listed in get_declared_classes()
        return new User(); // returns the error: Class 'Example\User' not found in /home/mylocal/apigility/module/Example/src/Example/Module.php on line *

如果在Apigility公用文件夹的 index.php 文件中使用相同的代码,则可以正常工作,其中没有来自Example命名空间的干扰。

0 个答案:

没有答案