benyanke/laravel-ntlm-soap
Composer 安装命令:
composer require benyanke/laravel-ntlm-soap
包简介
A SoapClient wrapper integration for Laravel with NTLM support
README 文档
README
A SoapClient wrapper integration for Laravel, built on top of jamesiarmes/php-ntlm.
Makes it easy to use Soap in a Laravel application.
Please report any bugs or features here:
https://github.com/benyanke/laravel-ntlm-soap/issues/
Installation
Laravel
Add benyanke/laravel-ntlm-soap as requirement to composer.json
{ "require": { "benyanke/laravel-ntlm-soap": "0.1.*" } }
Add the service provider in app/config/app.php.
'benyanke\SoapWrapper\ServiceProvider'
To use the facade add this to the facades in app/config/app.php.
'SoapWrapper' => 'benyanke\SoapWrapper\Facade'
Lumen
Open bootstrap/app.php and register the required service provider:
$app->register(benyanke\SoapWrapper\ServiceProvider::class);
register class alias:
class_alias('benyanke\SoapWrapper\Facade', 'SoapWrapper');
Facades must be enabled.
Usage
How to add a service to the wrapper and use it.
<?php namespace App\Http\Controllers; use benyanke\SoapWrapper\SoapWrapper; use App\Soap\Request\GetConversionAmount; use App\Soap\Response\GetConversionAmountResponse; class SoapController { /** * @var SoapWrapper */ protected $soapWrapper; /** * SoapController constructor. * * @param SoapWrapper $soapWrapper */ public function __construct(SoapWrapper $soapWrapper) { $this->soapWrapper = $soapWrapper; } /** * Use the SoapWrapper */ public function show() { $this->soapWrapper->add('Currency', function ($service) { $service ->wsdl('http://currencyconverter.kowabunga.net/converter.asmx?WSDL') ->trace(true) ->classmap([ GetConversionAmount::class, GetConversionAmountResponse::class, ]); }); // Without classmap $response = $this->soapWrapper->call('Currency.GetConversionAmount', [ 'CurrencyFrom' => 'USD', 'CurrencyTo' => 'EUR', 'RateDate' => '2014-06-05', 'Amount' => '1000', ]); var_dump($response); // With classmap $response = $this->soapWrapper->call('Currency.GetConversionAmount', [ new GetConversionAmount('USD', 'EUR', '2014-06-05', '1000') ]); var_dump($response); exit; } }
Service functions
$this->soapWrapper->add('Currency', function ($service) { $service ->wsdl() // The WSDL url ->trace(true) // Optional: (parameter: true/false) ->header() // Optional: (parameters: $namespace,$name,$data,$mustunderstand,$actor) ->customHeader() // Optional: (parameters: $customerHeader) Use this to add a custom SoapHeader or extended class ->cookie() // Optional: (parameters: $name,$value) ->location() // Optional: (parameter: $location) ->certificate() // Optional: (parameter: $certLocation) ->cache(WSDL_CACHE_NONE) // Optional: Set the WSDL cache // Optional: Set some extra options ->options([ 'login' => 'username', 'password' => 'password' ]) // Optional: Classmap ->classmap([ GetConversionAmount::class, GetConversionAmountResponse::class, ]); });
Classmap
If you are using classmap you can add folders like for example:
- App\Soap
- App\Soap\Request
- App\Soap\Response
Request: App\Soap\Request\GetConversionAmount
<?php namespace App\Soap\Request; class GetConversionAmount { /** * @var string */ protected $CurrencyFrom; /** * @var string */ protected $CurrencyTo; /** * @var string */ protected $RateDate; /** * @var string */ protected $Amount; /** * GetConversionAmount constructor. * * @param string $CurrencyFrom * @param string $CurrencyTo * @param string $RateDate * @param string $Amount */ public function __construct($CurrencyFrom, $CurrencyTo, $RateDate, $Amount) { $this->CurrencyFrom = $CurrencyFrom; $this->CurrencyTo = $CurrencyTo; $this->RateDate = $RateDate; $this->Amount = $Amount; } /** * @return string */ public function getCurrencyFrom() { return $this->CurrencyFrom; } /** * @return string */ public function getCurrencyTo() { return $this->CurrencyTo; } /** * @return string */ public function getRateDate() { return $this->RateDate; } /** * @return string */ public function getAmount() { return $this->Amount; } }
Response: App\Soap\Response\GetConversionAmountResponse
<?php namespace App\Soap\Response; class GetConversionAmountResponse { /** * @var string */ protected $GetConversionAmountResult; /** * GetConversionAmountResponse constructor. * * @param string */ public function __construct($GetConversionAmountResult) { $this->GetConversionAmountResult = $GetConversionAmountResult; } /** * @return string */ public function getGetConversionAmountResult() { return $this->GetConversionAmountResult; } }
benyanke/laravel-ntlm-soap 适用场景与选型建议
benyanke/laravel-ntlm-soap 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.02k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2017 年 10 月 02 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「client」 「soap」 「wrapper」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 benyanke/laravel-ntlm-soap 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 benyanke/laravel-ntlm-soap 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 benyanke/laravel-ntlm-soap 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
A PHP client for the Salesforce SOAP API
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
A Yii2 component for working with TurboSMS.ua SOAP service
Zend Framework 1 Soap package
统计信息
- 总下载量: 3.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-10-02