Akshay Khale
Akshay Khale

Reputation: 8371

PHP Soapclient in Laravel 5

I want to use PHP's built-in SoapClient class in Laravel 5

I tried using it directly but it shows an error saying

Class 'App\Http\Controllers\SoapClient' not found.

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

'SoapClient' => SoapClient::class

Still not working

what should I do?

Thanks in Advance...

Upvotes: 12

Views: 45529

Answers (3)

tristanbailey
tristanbailey

Reputation: 4615

You need to have libxml and soap extensions installed for it to load the SoapClient class.

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

For php 7.2 this would be needed to apt install and restart php/server.

apt-get install libxml php7.2-soap

Then check your php ini again. ubuntu ini path for the conf

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

extension=soap.so

After that you should be able to run new object command.

Upvotes: 0

Serdar D.
Serdar D.

Reputation: 3391

I faced with same problem.

I activated Soap extension after I use php artisan serve command and although I restarted my apache server I received same error..

After too many tries I stop artisan and restart it again and that was the solution for me.

Upvotes: 2

Joel Hinz
Joel Hinz

Reputation: 25414

The class needs to be imported, so either do that at the top:

use SoapClient;

or reference it directly later:

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

Upvotes: 40

Related Questions