Laravel 5 中的 PHP Soapclient

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33461588/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:30:17  来源:igfitidea点击:

PHP Soapclient in Laravel 5

phplaravellaravel-5soap-client

提问by Akshay Khale

I want to use php's built in SoapClientclass in laravel 5

我想在 Laravel 5 中使用 php 内置的SoapClient

I tried using it directly is shows error saying

我尝试直接使用它是显示错误说

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

找不到类“App\Http\Controllers\SoapClient”。

I tried adding SoapClientin aliases array in config/app.phplike this

我尝试像这样添加SoapClient别名数组config/app.php

'SoapClient' => SoapClient::class

Still not working

还是行不通

what should I do?

我该怎么办?

Thanks in Advance...

提前致谢...

回答by Joel Hinz

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

需要导入该类,因此要么在顶部执行此操作:

use SoapClient;

use SoapClient;

or reference it directly later:

或稍后直接引用:

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

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

回答by Serdar De?irmenci

I faced with same problem.

我遇到了同样的问题。

I activated Soap extension afterI use php artisan servecommand and although I restarted my apache server I received same error..

使用php artisan serve命令激活了 Soap 扩展,虽然我重新启动了我的 apache 服务器,但我收到了同样的错误..

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

经过太多次尝试后,我停止了 artisan 并重新启动它,这就是我的解决方案。

回答by tristanbailey

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

您需要为它安装 libxml 和 soap 扩展以加载 SoapClient 类。

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

因此,请检查php -i | grep limxmlphp -i | grep soap查看它们是否已安装。

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

对于 php 7.2,这需要 apt 安装和重启 php/server。

apt-get install libxml php7.2-soap

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

然后再次检查您的php ini。conf 的 ubuntu ini 路径

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

extension=soap.so

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

之后,您应该能够运行新对象命令。