[英]PHP: Fatal error: Class 'SoapClient' not found
首先,我已经阅读了这个问题( 致命错误:未找到类“SoapClient” )并且已经完成了答案所说的一切。 但仍然遇到问题。
我在这里也发现了类似的问题( https://bugs.php.net/bug.php?id=64445 ),但它也没有在那里解决。
我正在尝试在 Win 7 64 上设置 PHP + Apache 环境。
PHP :php-5.5.17-Win32-VC11-x86。 线程安全。
阿帕奇:httpd-2.4.10-win32-VC11
所以,这是我用于 SOAP 的C:\\PHP\\php.ini
。 一切都设置正确:
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
在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
我错过了什么? 如何解决?
这很容易。
我认为您使用 Symfony2 并使用名称空间。 此函数位于根命名空间中。
用:
\SoapClient()
否则你在命名空间中,他们找不到这个类。
例如,您对Exception
类有同样的问题。
如果您使用的是 linux 并且您缺少 soap 扩展名,就像我一样,并且您已经在 php.ini 中启用了它,然后尝试
apt-get install php-soap
service apache2 restart
我在自定义模块 Drupal 8 中遇到了同样的问题。
它使用 Symfony2,所以只需在控制器中添加:
use SoapClient;
在 PHP/7.4.11 服务器中
在 XAMPP 控制面板中
这个步骤解决了我的问题。
尝试使用路径配置扩展:
extension=ext/php_soap.dll
在phpinfo()
您可以看到以下重要行:
Configuration File (php.ini) Path C:\WINDOWS
Loaded Configuration File C:\Apache24\bin\php.ini
但是如果需要,您可以在 httpd.conf 中更改 ini 文件夹:
# configure the path to php.ini
#PHPIniDir "C:/php"
但是看看你使用的是什么扩展目录:
extension_dir C:\php
在“核心”部分。 这也可以配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.