Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/notfalsedev/laravel-soap
A soap client wrapper for Laravel
https://github.com/notfalsedev/laravel-soap
laravel lumen php soap
Last synced: 3 months ago
JSON representation
A soap client wrapper for Laravel
- Host: GitHub
- URL: https://github.com/notfalsedev/laravel-soap
- Owner: notfalsedev
- License: mit
- Created: 2014-08-06T07:41:47.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-11-26T18:24:24.000Z (about 3 years ago)
- Last Synced: 2024-05-20T02:10:05.207Z (9 months ago)
- Topics: laravel, lumen, php, soap
- Language: PHP
- Homepage:
- Size: 49.8 KB
- Stars: 630
- Watchers: 18
- Forks: 122
- Open Issues: 54
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Laravel SoapClient Wrapper
===========================A SoapClient wrapper integration for Laravel.
Makes it easy to use Soap in a Laravel application.Please report any bugs or features here:
https://github.com/artisaninweb/laravel-soap/issues/Installation
============## Laravel
####Installation for Laravel 5.2 and above:
Run `composer require artisaninweb/laravel-soap`
Add the service provider in `app/config/app.php`.
```php
Artisaninweb\SoapWrapper\ServiceProvider::class,
```To use the alias, add this to the aliases in `app/config/app.php`.
```php
'SoapWrapper' => Artisaninweb\SoapWrapper\Facade\SoapWrapper::class,
```####Installation for Laravel 5.1 and below :
Add `artisaninweb/laravel-soap` as requirement to composer.json
```javascript
{
"require": {
"artisaninweb/laravel-soap": "0.3.*"
}
}
```> If you're using Laravel 5.5 or higher you can skip the two config setups below.
Add the service provider in `app/config/app.php`.
```php
'Artisaninweb\SoapWrapper\ServiceProvider'
```To use the facade add this to the facades in `app/config/app.php`.
```php
'SoapWrapper' => 'Artisaninweb\SoapWrapper\Facade'
```## Lumen
Open `bootstrap/app.php` and register the required service provider:
```php
$app->register(Artisaninweb\SoapWrapper\ServiceProvider::class);
```register class alias:
```php
class_alias('Artisaninweb\SoapWrapper\Facade', 'SoapWrapper');
```*Facades must be enabled.*
Usage
============How to add a service to the wrapper and use it.
```php
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
============
```php
$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\ResponseRequest: App\Soap\Request\GetConversionAmount
```php
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
GetConversionAmountResult = $GetConversionAmountResult;
}/**
* @return string
*/
public function getGetConversionAmountResult()
{
return $this->GetConversionAmountResult;
}
}
```