Figen Güngör
Figen Güngör

Reputation: 12559

Fatal error: Class 'SoapClient' not found

I'm trying a simple web service example and I get this error even though I uncommented extension=php_soap.dll in the php.ini file:

Fatal error: Class 'SoapClient' not found in C:\Program Files (x86)\EasyPHP-5.3.9\www\server.php on line 2

Upvotes: 253

Views: 500151

Answers (16)

yavuz16dev
yavuz16dev

Reputation: 117

With wamp server and php 8 :

Right-click on the WampServer icon in the system tray. enter image description here

Enable the SOAP extension:

Go to "PHP Extensions" (or a similar option) and make sure that the SOAP extension is checked or enabled.

enter image description here

Restart WampServer services:

Right-click on the WampServer icon and select "Restart All Services."

Upvotes: 1

M Shafaei N
M Shafaei N

Reputation: 449

I had a similar problem. It was due to the scope and solved by replacing new SoapClient by new \SoapClient.

Upvotes: 0

Yassine ECHCHARAFI
Yassine ECHCHARAFI

Reputation: 660

For PHP 7.4 & Docker add this line in Dockerfile:

RUN apt-get update && apt-get install -y \
libxml2-dev \

RUN docker-php-ext-install soap

Rebuild the image and restart ;)

Upvotes: 4

sh6210
sh6210

Reputation: 4530

In my case, the Symfony cache was causing the problem, after running composer install the problem was gone.

Upvotes: 0

shikata
shikata

Reputation: 95

For PHP 8:

sudo apt update
sudo apt-get install php8.0-soap

Upvotes: 0

PJunior
PJunior

Reputation: 2767

On Centos 7.8 and PHP 7.3

yum install php-soap
service httpd restart

Upvotes: 1

Jakub Adamec
Jakub Adamec

Reputation: 1124

For XAMPP users, open php.ini file located in C:/xampp/php and remove the ; from the beginning of extension=soap. Then restart Apache and that's it!

Upvotes: 13

Nahid
Nahid

Reputation: 3045

To install SOAP in PHP-7 run following in your Ubuntu terminal:

sudo apt-get install php7.0-soap

To install SOAP in PHP-7.1 run following in your Ubuntu terminal:

sudo apt-get install php7.1-soap

To install SOAP in PHP-7.2 run following in your Ubuntu terminal:

sudo apt-get install php7.2-soap

To install SOAP in PHP-7.3 run following in your Ubuntu terminal:

sudo apt-get install php7.3-soap

Upvotes: 183

Attila Fulop
Attila Fulop

Reputation: 7011

For Docker* add this line:

RUN apt-get update && \
    apt-get install -y libxml2-dev && \
    docker-php-ext-install soap

*: For debian based images, ie. won't work for alpine variants.

Upvotes: 6

Nanhe Kumar
Nanhe Kumar

Reputation: 16297

I solved this issue on PHP 7.0.22-0ubuntu0.16.04.1 nginx

sudo apt-get install php7.0-soap

sudo systemctl restart php7.0-fpm
sudo systemctl restart nginx

Upvotes: 9

Jasom Dotnet
Jasom Dotnet

Reputation: 1307

To install SOAP in PHP5.6 run following in your Ubuntu 14.04 terminal:

sudo apt-get install php5.6-soap
service php5.6-fpm restart
service apache2 restart

See if SOAP was enabled:

php -m

(You should see SOAP between returned text.)

Upvotes: 18

user680786
user680786

Reputation:

For AWS (RHEL):

sudo yum install php56-soap

(56 here is 5.6 PHP version - put your version here).

Upvotes: 22

MayTheSForceBeWithYou
MayTheSForceBeWithYou

Reputation: 326

I had to run

php-config --configure-options --enable-soap 

as root and restart apache.

That worked! Now my phpinfo() call shows the SOAP section.

Upvotes: 11

RafaSashi
RafaSashi

Reputation: 17205

I couln't find the SOAP section in phpinfo() so I had to install it.

For information the SOAP extension requires the libxml PHP extension. This means that passing in --enable-libxml is also required according to http://php.net/manual/en/soap.requirements.php

From WHM panel

  1. Software » Module Installers » PHP Extensions & Applications Package
  2. Install SOAP 0.13.0

    WARNING: "pear/HTTP_Request" is deprecated in favor of "pear/HTTP_Request2"

    install ok: channel://pear.php.net/SOAP-0.13.0

  3. Install HTTP_Request2 (optional)

    install ok: channel://pear.php.net/HTTP_Request2

  4. Restart Services » HTTP Server (Apache)

From shell command

1.pear install SOAP

2.reboot

Upvotes: 8

Wondie
Wondie

Reputation: 65

You have to inherit nusoap.php class and put it in your project directory, you can download it from the Internet.

Use this code:

require_once('nusoap.php');

Upvotes: 0

Morgan Wilde
Morgan Wilde

Reputation: 17295

Diagnose

Look up the following inside your script file

phpinfo();

If you can't find Soap Client set to enabled like so: the way soap should appear in phpinfo()

Fix

Do the following:

  1. Locate php.ini in your apache bin folder, I.e Apache/bin/php.ini
  2. Remove the ; from the beginning of extension=php_soap.dll
  3. Restart your Apache server
  4. Look up your phpinfo(); again and check if you see a similar picture to the one above
  5. If you do, problem solved!

On the other hand if this doesn't solve your issue, you may want to check the requirements for SOAP here. Also in the comment section you can find good advice on connecting to https.

Upvotes: 414

Related Questions