Fatal error: Class Soap Client not found

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

Here, I am sharing my understanding regarding this error. This error can be occurred on Linux as well as Windows system.

Checkout other PHP SOAP Tutorials,

There are following reason to occurred error:

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 be look like this:
extension=php_soap.dll

Now Restart your Apache server

Verify Soap Client Using php.ini

You can verify php soap is enabled orr not using php_info, Open php_info and search soap, if you ll found soap extension as like below, That’s mean you are good to run soap service –

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

Might be your extension_dir path sets relative path.

You need to un-comment the extension_dir line if its 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"

It should be look like this:
extension_dir="C:/php/ext"