PHP:致命错误:找不到“SoapClient”类

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26383946/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 22:53:00  来源:igfitidea点击:

PHP: Fatal error: Class 'SoapClient' not found

phpapachesoap

提问by Green

First of all, I've read this question (Fatal error: Class 'SoapClient' not found) and have everything done the answer says. But still experience an issue.

首先,我已经阅读了这个问题(致命错误:未找到类“SoapClient”)并且已经完成了答案所说的一切。但仍然遇到问题。

I also found similar issue here (https://bugs.php.net/bug.php?id=64445) but it is not solved there too.

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

I'm trying to set up a PHP + Apache environment on Win 7 64.

我正在尝试在 Win 7 64 上设置 PHP + Apache 环境。

  1. PHP: php-5.5.17-Win32-VC11-x86. Thread safe.

  2. Apache: httpd-2.4.10-win32-VC11

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

  2. 阿帕奇:httpd-2.4.10-win32-VC11

So, here is my C:\PHP\php.inifor SOAP. Everything is set correctly:

所以,这是我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

In C:/PHP/extfolder I have php_soap.dllfile, C:\PHP\ext\php_soap.dll.

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

But my phpinfo();returns ONLYthis about SOAP:

但我phpinfo();返回关于 SOAP 的这一点:

enter image description here

enter image description here

I DO NOThave these settings shown:

没有显示这些设置:

enter image description here

enter image description here

And I get error:

我得到错误:

Fatal error: Class 'SoapClient' not found in C:\Apache24\htdocs\myApp\src\Em\Bundle\PlatformBundle\Services\MyAppService.php on line 46

What did I miss? How to solve it?

我错过了什么?如何解决?

回答by René H?hle

This is very easy.

这很容易。

You work with Symfony2 i think and you use namespaces. This function is in the Root-Namespace.

我认为您使用 Symfony2 并使用名称空间。此函数位于根命名空间中。

use:

用:

\SoapClient()

Otherwise you are in the namespace and they can't find the class.

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

You have the same Problem with the Exceptionclass for example.

例如,您在Exception课堂上遇到了同样的问题。

回答by hounded

If you are on linux and you are missing the soap extension, like I was and you have already enabled it in php.ini then try

如果您使用的是 linux 并且您缺少 soap 扩展名,就像我一样,并且您已经在 php.ini 中启用了它,然后尝试

apt-get install php-soap
service apache2 restart

回答by Sébastien Gicquel

I had the same issue in a custom module Drupal 8.

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

It uses Symfony2 so just add this in controller :

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

use SoapClient;

回答by TO_REMOVE

Try config the extension using the path:

尝试使用路径配置扩展:

extension=ext/php_soap.dll

In phpinfo()you can see this important lines:

phpinfo()你可以看到这个重要的行:

Configuration File (php.ini) Path   C:\WINDOWS
Loaded Configuration File   C:\Apache24\bin\php.ini 

But you can change the ini folder if desire in httpd.conf:

但是如果需要,您可以在 httpd.conf 中更改 ini 文件夹:

# configure the path to php.ini
#PHPIniDir "C:/php"

BUT SEE what extension dir are you using:

但是看看你使用的是什么扩展目录:

extension_dir   C:\php

In the "Core" section. This can be configured too.

在“核心”部分。这也可以配置。