Fatal error: Class Soap Client not found

Today, I was creating a web service through SOAP Client in PHP. Unfortunately, I got below fatal error “Class ‘SoapClient’ not found” on applications. I spent some time on Google to find a solution and found a working solution.

Here, I am sharing my understanding regarding this error. This error can occur on Linux as well as Windows systems.

Check out other PHP SOAP Tutorials,

There are several reasons for this error to occur:

  • Linux: You do not have php-soap installed into the system.
  • Windows: You have not un-commented the following line out from the php.ini file.

Locate the php.ini file into xampp or wamp folder, The location would be your Apache bin folder, I.e Apache/bin/php.ini

By default, it looks like this:
;extension=php_soap.dll

It should appear like this:
extension=php_soap.dll

Let’s Restart your Apache server.

Verify Soap Client Using php.ini

You can check if PHP SOAP is enabled by using phpinfo. Open phpinfo (typically found at localhost/dashboard/phpinfo.php in XAMPP), then search for 'soap'. If you find the soap extension listed as shown below, it means you are ready to run SOAP services:

fatal-error-class-soapclient-not-found

Even if you are getting the same error on the Windows system that means your extension directory path is not set.

It might be your extension_dir path sets a relative path.

You need to un-comment the extension_dir line if it’s commented into php.ini file. rather, you may have to set an absolute path to the extensions directory.

Un-Comment extension_dir into php.ini file
We will open the php.ini file and search extension_dir into this file. By default, it looks like this:
;extension_dir="ext"

Ensure it appears as follows:
extension_dir="C:/php/ext"

Conclusion

We have addressed Class ‘SoapClient’ not found” error. we can fix it by ensuring the presence of necessary modules and correctly configuring php.ini.

3 thoughts on “Fatal error: Class Soap Client not found

  1. I had the same error… when I test code at the separate page – everything be OK, but when I include it into the target page – the error appeared.

    The solution is – input symbol ” ” before Class name => SoapClient(…)
    everything works! 🙂

    • you can get php information in your hosted PHP server, I am using xampp to run PHP application, the phpinfo path is : localhost/dashboard/phpinfo.php

Leave a Reply

Your email address will not be published. Required fields are marked *