PHP:致命错误:未找到类'SoapClient'

Gre*_*een 9 php apache soap

首先,我已经阅读了这个问题(致命错误:没有找到类'SoapClient')并且已经完成了所有工作.但仍然遇到问题.

我也在这里找到了类似的问题(https://bugs.php.net/bug.php?id=64445),但它也没有解决.

我正在尝试在Win 7 64上建立PHP + Apache环境.

  1. PHP:php-5.5.17-Win32-VC11-x86.线程安全.

  2. Apache:httpd-2.4.10-win32-VC11

所以,这是我C:\PHP\php.ini的SOAP.一切都设置正确:

extension=php_soap.dll

; Directory in which the loadable extensions (modules) reside.
; On windows:
extension_dir = "C:/PHP/ext"

[soap]
; Enables or disables WSDL caching feature.
; http://php.net/soap.wsdl-cache-enabled
soap.wsdl_cache_enabled=1

; Sets the directory name where SOAP extension will put cache files.
; http://php.net/soap.wsdl-cache-dir
soap.wsdl_cache_dir="/tmp"

; (time to live) Sets the number of second while cached file will be used
; instead of original one.
; http://php.net/soap.wsdl-cache-ttl
soap.wsdl_cache_ttl=86400

; Sets the size of the cache limit. (Max. number of WSDL files to cache)
soap.wsdl_cache_limit = 5
Run Code Online (Sandbox Code Playgroud)

C:/PHP/ext文件夹中我有php_soap.dll文件,C:\PHP\ext\php_soap.dll.

但我的phpinfo();回报只有 SOAP:

在此输入图像描述

没有显示以下设置:

在此输入图像描述

我得到错误:

Fatal error: Class 'SoapClient' not found in C:\Apache24\htdocs\myApp\src\Em\Bundle\PlatformBundle\Services\MyAppService.php on line 46
Run Code Online (Sandbox Code Playgroud)

我错过了什么?怎么解决?

Ren*_*hle 8

这很容易.

您使用Symfony2我认为您使用名称空间.此函数位于Root-Namespace中.

使用:

\SoapClient()
Run Code Online (Sandbox Code Playgroud)

否则你在命名空间中,他们找不到类.

例如,您对Exception类有相同的问题.

  • 对于未来的 Laravel 用户,也适合您,因为 Laravel 使用 Symfony。`使用 SoapClient;` (2认同)

hou*_*ded 5

如果您在Linux上并且缺少象我一样的soap扩展名,并且您已经在php.ini中启用了它,请尝试

apt-get install php-soap
service apache2 restart
Run Code Online (Sandbox Code Playgroud)


Séb*_*uel 5

我在自定义模块 Drupal 8 中遇到了同样的问题。

它使用 Symfony2,所以只需在控制器中添加:

use SoapClient;
Run Code Online (Sandbox Code Playgroud)