PHP: Fatal error: Class 'SoapClient' not found
Solution 1
This is very easy.
You work with Symfony2 i think and you use namespaces. This function is in the Root-Namespace.
use:
\SoapClient()
Otherwise you are in the namespace and they can't find the class.
You have the same Problem with the Exception
class for example.
Solution 2
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
apt-get install php-soap
service apache2 restart
Solution 3
I had the same issue in a custom module Drupal 8.
It uses Symfony2 so just add this in controller :
use SoapClient;
Solution 4
in PHP/7.4.11 Server
In XAMPP Control Panel
- Stop Apache Server
- Click on Config next to Apache
- From dropdown select PHP (php.ini)
- Ctrl+F to find ;extension=soap and remove ; from the line.
- Ctrl+S to save the file.
- Start Apache again.
this steps solved my problem.
Green
Node.js Angular, React, React-native JavaScript AWS Full Stack Web Developer from Ukraine.
Updated on August 01, 2022Comments
-
Green almost 2 years
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.
I also found similar issue here (https://bugs.php.net/bug.php?id=64445) but it is not solved there too.
I'm trying to set up a PHP + Apache environment on Win 7 64.
PHP: php-5.5.17-Win32-VC11-x86. Thread safe.
Apache: httpd-2.4.10-win32-VC11
So, here is my
C:\PHP\php.ini
for SOAP. Everything is set correctly: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/ext
folder I havephp_soap.dll
file,C:\PHP\ext\php_soap.dll
.But my
phpinfo();
returns ONLY this about SOAP:I DO NOT have these settings shown:
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?
-
Green over 9 yearsThat's right, I had
SoapClient()
class call without \. I put\SoapClient()
but the issue remains -
Marc Condon about 9 yearsThis is an especially stupid thing to research because of the confusion between Soap WSDL/XML Namespace and PHP Namespace. Thanks for the interpreting that correctly
-
Kenny Grage about 8 yearsFor future Laravel users, also for you too, as Laravel uses Symfony.
use SoapClient;