Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: Fatal error: Class 'SoapClient' not found

Tags:

php

soap

apache

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?

like image 489
Green Avatar asked Oct 15 '14 13:10

Green


3 Answers

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.

like image 166
René Höhle Avatar answered Nov 18 '22 02:11

René Höhle


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
like image 40
hounded Avatar answered Nov 18 '22 01:11

hounded


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

It uses Symfony2 so just add this in controller :

use SoapClient;
like image 5
Sébastien Gicquel Avatar answered Nov 18 '22 03:11

Sébastien Gicquel