14

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.

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

  2. 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 have php_soap.dll file, C:\PHP\ext\php_soap.dll.

But my phpinfo(); returns ONLY this about SOAP:

enter image description here

I DO NOT have these settings shown:

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?

Community
  • 1
  • 1
Green
  • 28,742
  • 61
  • 158
  • 247

5 Answers5

11

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.

René Höhle
  • 26,716
  • 22
  • 73
  • 82
  • That's right, I had `SoapClient()` class call without \. I put `\SoapClient()` but the issue remains – Green Oct 15 '14 at 13:53
  • This 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 – Marc Condon Mar 30 '15 at 21:41
  • 1
    For future Laravel users, also for you too, as Laravel uses Symfony. `use SoapClient;` – Kenny Grage May 18 '16 at 16:00
6

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
hounded
  • 666
  • 10
  • 21
5

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

It uses Symfony2 so just add this in controller :

use SoapClient;
Sébastien Gicquel
  • 4,227
  • 7
  • 54
  • 84
2

in PHP/7.4.11 Server

In XAMPP Control Panel

  1. Stop Apache Server
  2. Click on Config next to Apache
  3. From dropdown select PHP (php.ini)
  4. Ctrl+F to find ;extension=soap and remove ; from the line.
  5. Ctrl+S to save the file.
  6. Start Apache again.

this steps solved my problem.

Ali Yazdanifar
  • 372
  • 4
  • 12
0

Try config the extension using the path:

extension=ext/php_soap.dll

In phpinfo() you can see this important lines:

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:

# 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.

Michael
  • 2,631
  • 2
  • 24
  • 40