[php] 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

This question is related to php soap fatal-error

The answer is


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

For AWS (RHEL):

sudo yum install php56-soap

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


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!


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


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');

For PHP 8:

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

On Centos 7.8 and PHP 7.3

yum install php-soap
service httpd restart

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


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.


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

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.


Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to soap

No found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: There was no endpoint listening at (url) that could accept the message How to enable SOAP on CentOS SOAP-ERROR: Parsing WSDL: Couldn't load from - but works on WAMP SOAP vs REST (differences) SOAP request to WebService with java How to consume a SOAP web service in Java Sending SOAP request using Python Requests JSON, REST, SOAP, WSDL, and SOA: How do they all link together What is the difference between JAX-RS and JAX-WS?

Examples related to fatal-error

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 71 bytes) PHP Notice: Undefined offset: 1 with array when reading data PHP Fatal error: Cannot access empty property PHP Fatal error when trying to access phpmyadmin mb_detect_encoding Fatal error: Class 'SoapClient' not found Cannot redeclare function php C++ Fatal Error LNK1120: 1 unresolved externals A fatal error has been detected by the Java Runtime Environment: SIGSEGV, libjvm Why, Fatal error: Class 'PHPUnit_Framework_TestCase' not found in ...? relative path in require_once doesn't work