【问题标题】:using SoapClient,ArrayObject, ArrayIterator causes error in zend framework在 zend 框架中使用 SoapClient、ArrayObject、ArrayIterator 会导致错误
【发布时间】:2012-07-07 20:18:35
【问题描述】:

我正在我的实体中研究一些有用的方法。

private function setApi($api_address,$api_username,$api_password){

    $this->api_address = $api_address;
    $this->api_username = $api_username;
    $this->api_password = $api_password;
    $this->api_client = new SoapClient($api_address); // error
}

警告:require(App/Entity/SoapClient.php):无法打开流:第 148 行的 /zendboilerplate/library/Doctrine/Common/ClassLoader.php 中没有这样的文件或目录致命错误:require():失败打开所需的 'App/Entity/SoapClient.php' (include_path='/zendboilerplate/application/../library:/zendboilerplate/application/../library/Bisna/Application/Resource:/zendboilerplate/library:.:/usr /share/php:/usr/share/pear') 在 /zendboilerplate/library/Doctrine/Common/ClassLoader.php 第 148 行 似乎 zend 寻找一个类声明(并且它不使用 php 中包含的类)。

每个“new Class”声明都有相同的错误。 使用库中包含的我自己的类,一切正常。 (也尝试使用 @new SoapClient() 但没有结果)。

【问题讨论】:

  • PHP 是否使用提供此类的--enable-soap 开关进行配置?您在使用自己的自动加载器吗?
  • 在控制器中 new SoapClient() 运行良好,在 library/App/Entity/MyEntity.php 中会导致错误。所以我认为这与配置无关。
  • 我正在使用 zend 样板,我不知道自动加载器是否会导致这种情况。我可以在哪里查看有关自动加载器的信息?
  • 在函数autoload 中尝试在Zend/Loader/Autoloader.php 中的断点/调试点,看看它是否正在尝试自动加载SoapClient。这应该是负责在 ZF 最新版本中自动加载的文件。出于某种原因,它认为在 App/Entity/SoapClient.php 中查找该课程。也许尝试在调用new SoapClient 之前加上var_dump(class_exists('SoapClient', false)); 看看会发生什么。
  • Doctrine/Common/ClassLoader.php 这里自动加载所有类: public function loadClass($className) { if ($this->namespace !== null && strpos($className, $this->namespace .$this->namespaceSeparator) !== 0) { return false; } 需要 ($this->includePath !== null ? $this->includePath . DIRECTORY_SEPARATOR : '') 。 str_replace($this->namespaceSeparator, DIRECTORY_SEPARATOR, $className) 。 $this->文件扩展名;返回真; }

标签: zend-framework doctrine-orm zend-autoloader


【解决方案1】:

我猜这是命名空间相关的。尝试将出错的行更改为:

$this->api_client = new \SoapClient($api_address);

这应该强制它使用 PHP SoapClient 而不是可能在您遇到问题的文件开头声明的命名空间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-05-17
    • 1970-01-01
    • 2018-01-12
    • 2013-07-07
    • 2013-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多