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


Solution 1:

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.

Solution 2:

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

Solution 3:

For AWS (RHEL):

sudo yum install php56-soap

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

Solution 4:

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

Solution 5:

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.