【问题标题】:Zend 1 3d party NameSpaces autoload don't workingZend 1 3d 派对名称空间自动加载不起作用
【发布时间】:2015-08-01 21:15:59
【问题描述】:

我正在尝试将 Amazon WebServices PHP SDK 实施到我的 Zend 1 项目中,但似乎无法加载类。

我已将库放入library/Eplan/AmazonCloudSearch,经过调查,似乎为了能够加载命名空间,我需要从Zend_Loader_Autoloader::getInstance() 调用registerNamespace 方法,所以我把它放在了顶部自动加载器(我也试过把它放在引导程序中,但运气不好):

require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace("Aws");

AWS 库的命名空间如下:Aws\namespace

我得到的错误类似于Warning: include_once(Aws/Common/Aws.php): failed to open stream: No such file or directory in /srv/www_nfs_desarrollo/vhosts/desarrollo.techmaker.net/httpdocs/library/Zend/Loader.php on line 134

自动加载器完整代码:http://pastebin.com/gS9mcntK

我整天都在努力解决这个问题,但没有运气,有什么想法吗?

【问题讨论】:

    标签: php zend-framework amazon-web-services namespaces autoloader


    【解决方案1】:

    为了使用$autoloader->registerNamespace('Aws'),您寻找的AWS 库必须位于您的PHP 包含路径中,该路径可能包括您的./library 目录。相反,您将 AWS 库埋在 ./library/Eplan/AmazonCloudSearch 中,几乎可以肯定它不是在您的 PHP include_path 中。

    尝试将 AWS 库向上移动两个级别,直接进入 ./library 目录。

    【讨论】:

    • 您也可以使用includePaths.myPath = APPLICATION_PATH "/../wherever/it/may/be"将包含路径添加到您的application.ini文件中
    【解决方案2】:

    您可以使用以下代码使用 application.ini 文件自动加载。

    autoloaderNamespaces[] = "Aws"

    【讨论】:

      猜你喜欢
      • 2012-03-10
      • 2014-12-05
      • 2011-09-18
      • 1970-01-01
      • 2014-10-25
      • 2013-11-19
      • 2023-03-27
      • 1970-01-01
      • 2013-06-11
      相关资源
      最近更新 更多