2

I am using PHP 7.4 and Laravel 8 to create an app.

I am trying to send an SMS like this:

...
...
$this->client = new \SoapClient('http://ippanel.com/class/sms/wsdlservice/server.php?wsdl');
$this->user = '****';
$this->pass = '****';
$this->fromNum = '****';
...
...

But I get this error:

Error: Class 'SoapClient' not found in /usr/local/lsws/IRMine/html/core/app/Classes/ippanelSMS.php

And I already installed and enabled php-soap in my server:

phpinfo

So what could my problem be??

K1-Aria
  • 1,093
  • 4
  • 21
  • 34
  • 1
    Have you tried removing the `;` from the beginning of `extension=php_soap.dll` in `php.ini`? And restart your server. – S N Sharma Aug 17 '21 at 05:19
  • Q: Do you have `use SoapClient;` anywhere? – paulsm4 Aug 17 '21 at 05:21
  • i installed the soap using command and i did not have this line in php.ini, but yes i added this line to the file and restart the server and the problem still exist – K1-Aria Aug 17 '21 at 05:23
  • @paulsm4 i tried that too. but problem still exist – K1-Aria Aug 17 '21 at 05:23
  • 1
    https://stackoverflow.com/questions/11391442/fatal-error-class-soapclient-not-found – VIKAS KATARIYA Aug 17 '21 at 05:25
  • I would create a service layer to do this, if your code shared is already the service layer, I would switch to use `Guzzle` as it is the standard `Client`, so if you later change to `REST API` you don't have to do a big effort to change to it, you have to change small things in your Guzzle request and it will be less work. Also it will help you see if you have any errors here. Check this [SO Question](https://stackoverflow.com/questions/19170846/using-guzzle-to-consume-soap) and it's answers. – matiaslauriti Aug 17 '21 at 05:25
  • @Vikas Katariya it did not help... – K1-Aria Aug 17 '21 at 05:31
  • what is the value of `Loaded Configuration File` in `phpinfo()` ? – Abolfazl Mohajeri Aug 17 '21 at 06:20
  • @AbolfazlMohajeri its: /usr/local/lsws/lsphp74/etc/php.ini – K1-Aria Aug 17 '21 at 06:23
  • Read the error logs. Also, do you have `libxml2-dev` installed? – Zoli Szabó Aug 17 '21 at 07:39
  • @ZoliSzabó no. what is that for? – K1-Aria Aug 17 '21 at 07:43
  • 1
    Well, SOAP is an XML-based protocol. And as far as I remember it is a prerequisite. Do you have the PHP libxml extension enabled (although I think the SOAP extension could not be enabled without libxml being already active)? – Zoli Szabó Aug 17 '21 at 07:54
  • right. I just checked and this module was installed too. (libxml) – K1-Aria Aug 17 '21 at 08:00
  • unfortunately this problem is still unsolved – K1-Aria Aug 21 '21 at 04:44

1 Answers1

1

First use should check your if your module is really loaded by execution this command:

var_dump(extension_loaded('soap'));

Also you should check the path of your loaded configuration

var_dump( get_cfg_var('cfg_file_path') );

It could be that the module is only activated for the CLI, so you should double check that your configuration is correct.

Roman
  • 2,530
  • 2
  • 27
  • 50
  • thank you. the first output was: bool(true). and the second: string(35) "/usr/local/lsws/lsphp74/etc/php.ini". – K1-Aria Aug 17 '21 at 07:06
  • 2
    There's nothing wrong with using `\SoapClient` (with the explicit `\\`). In fact, it might not work without it if there is a namespace declaration in the file calling the Soap client; and since it is a Laravel app, there's a strong chance there is a namespace declaration at the top of the file. – Zoli Szabó Aug 17 '21 at 07:07
  • 1
    Thanks @ZoliSzabó - i improved my answer. – Roman Aug 17 '21 at 07:15
  • thanks guys. it seems i installed and enabled the soap in my server well. but the error still exist – K1-Aria Aug 17 '21 at 07:16