kduma / laravel-soap-server
Laravel SOAP service server
Installs: 14 146
Dependents: 0
Suggesters: 0
Security: 0
Stars: 19
Watchers: 3
Forks: 4
Open Issues: 1
Requires
- php: ^7.4|^8.0|^8.1|^8.2
- ext-soap: *
- laminas/laminas-soap: ^2.11
Requires (Dev)
- orchestra/testbench: ^4.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-11-04 07:21:36 UTC
README
Laravel SOAP service server
Installation
You can install the package via composer:
composer require kduma/laravel-soap-server
Usage
Create server class - remember to provide correct typehints and doc blocks:
class SoapDemoServer { /** * Adds two numbers * * @param float $a * @param float $b * * @return float */ public function sum(float $a = 0, float $b = 0): float { return $a + $b; } /** * Returns your data * * @return Person */ public function me(): Person { return new Person('John', 'Doe'); } /** * Says hello to person provided * * @param Person $person * * @return string */ public function hello(Person $person): string { return sprintf("Hello %s!", $person->first_name); } }
...and DTO objects:
class Person { /** * @var string */ public $first_name; /** * @var string */ public $last_name; /** * @param string $first_name * @param string $last_name */ public function __construct(string $first_name, string $last_name) { $this->first_name = $first_name; $this->last_name = $last_name; } }
Create controller class for your SOAP server:
class MySoapController extends \KDuma\SoapServer\AbstractSoapServerController { protected function getService(): string { return SoapDemoServer::class; } protected function getEndpoint(): string { return route('my_soap_server'); } protected function getWsdlUri(): string { return route('my_soap_server.wsdl'); } protected function getClassmap(): array { return [ 'SoapPerson' => Person::class, ]; } }
Register routes in your routes file:
Route::name('my_soap_server.wsdl')->get('/soap.wsdl', [MySoapController::class, 'wsdlProvider']); Route::name('my_soap_server')->post('/soap', [MySoapController::class, 'soapServer']);
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email git@krystian.duma.sh instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.