PHP Soapclient in Laravel 5

I want to use php built into SoapClient class in laravel 5

I tried to use it directly, it shows an error, saying

The class "Application \ Http \ Controllers \ SoapClient" was not found.

I tried adding SoapClient to the aliases array in config/app.php , like this

 'SoapClient' => SoapClient::class 

Does not work

what should I do?

Thanks at Advance ...

+8
source share
3 answers

The class must be imported, so either do this at the top:

use SoapClient;

or refer to it directly later:

$client = new \SoapClient($wsdl, $options);

+30
source

I faced the same problem.

I activated the Soap extension after . I am using the php artisan serve command, and although I restarted my Apache server, I got the same error.

After too many attempts, I stop working and restart it again, and this solution is for me.

0
source

To load the SoapClient class, you need to install the libxml and soap extensions.

So check php -i | grep limxml php -i | grep limxml and php -i | grep soap php -i | grep soap to see if they are installed.

For php 7.2 it is necessary to install and restart php / server.

 apt-get install libxml php7.2-soap 

Then check your php ini again. Ubuntu INI path for conf.

 /etc/php/7.2/cli/conf.d/20-soap.ini extension=soap.so 

After that, you will be able to run a new object command.

0
source

All Articles