phpro / soap-client
A general purpose SoapClient library
Fund package maintenance!
Open Collective
Installs: 3 634 272
Dependents: 43
Suggesters: 1
Security: 0
Stars: 860
Watchers: 23
Forks: 174
Open Issues: 2
Requires
- php: ~8.2.0 || ~8.3.0 || ~8.4.0
- azjezz/psl: ^3.0
- laminas/laminas-code: ^4.14.0
- php-soap/cached-engine: ~0.3
- php-soap/encoding: ~0.14
- php-soap/engine: ^2.14.0
- php-soap/psr18-transport: ^1.7
- php-soap/wsdl-reader: ~0.20
- psr/event-dispatcher: ^1.0
- psr/log: ^1.0 || ^2.0 || ^3.0
- symfony/console: ~5.4 || ~6.0 || ~7.0
- symfony/event-dispatcher: ~5.4 || ~6.0 || ~7.0
- symfony/filesystem: ~5.4 || ~6.0 || ~7.0
- symfony/validator: ~5.4 || ~6.0 || ~7.0
Requires (Dev)
- guzzlehttp/guzzle: ^7.5.0
- nyholm/psr7: ^1.5
- php-http/vcr-plugin: ^1.2
- php-parallel-lint/php-parallel-lint: ^1.3
- phpro/grumphp-shim: ^2.9
- phpspec/phpspec: ~7.2
- phpspec/prophecy-phpunit: ^2.0.1
- phpstan/phpstan: ^1.12.7
- phpunit/phpunit: ~10.5.37
- squizlabs/php_codesniffer: ^3.7.1
- symfony/cache: ^6.4 || ^7.0
- v4.x-dev
- 4.0.0-alpha4
- 4.0.0-alpha3
- 4.0.0-alpha2
- 4.0.0-alpha1
- v3.x-dev
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.2
- 3.1.1
- 3.1.0
- 3.0.0
- 3.0.0-alpha1
- v2.x-dev
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.0
- v2.2.1
- v2.2.0
- v2.1.0
- v2.0.0
- v1.7.x-dev
- v1.7.4
- v1.7.3
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.1
- v1.4.0
- v1.3.2
- v1.3.1
- v1.3.0
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.5
- v1.0.4
- v1.0.3
- 1.0.2
- v1.0.1
- v1.0.0
- 0.7.11
- 0.7.10
- 0.7.9
- 0.7.8
- 0.7.7
- 0.7.6
- 0.7.5
- 0.7.4
- 0.7.3
- 0.7.2
- 0.7.1
- 0.7.0
- 0.6.1
- 0.6.0
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.0
- v0.3.1
- v0.3.0
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.4
- v0.1.3
- v0.1.2
- v0.1.1
- v0.1.0
This package is auto-updated.
Last update: 2024-12-19 12:43:31 UTC
README
General purpose PHP SOAP-client
Sick and tired of building crappy SOAP implementations? This package aims to help you with some common SOAP integration pains in PHP. Its goal is to make integrating with SOAP fun again!
Demo
Want to help out? 💚
Want more information about the future of this project? Check out this list of the next big projects we'll be working on.
Prerequisites
You can choose what HTTP client you want to use. This package expects some PSR implementations to be present in order to be installed:
- PSR-6:
psr/cache-implementation
likesymfony/cache
orcache/*-adapter
- PSR-7:
psr/http-message-implementation
likenyholm/psr7
orguzzlehttp/psr7
- PSR-17:
psr/http-factory-implementation
likenyholm/psr7
orguzzlehttp/psr7
- PSR-18:
psr/http-client-implementation
likesymfony/http-client
orguzzlehttp/guzzle
Example:
$ composer require symfony/http-client nyholm/psr7
Installation
$ composer require phpro/soap-client
Scafolding Wizard
Since life is too short to read documentation, we've added a scafolding wizard which will get you communicating with your SOAP server in no time! All you need to do is:
./vendor/bin/soap-client wizard
You can customize the generated code based on the manual installation pages in the next chapter.
Getting your SOAP integration up and running
- Create your own SOAP client.
- Generate PHP classes based on SOAP types.
- Generate a class map
- Generate your own SOAP client.
- Generate a client factory.
- Use your SOAP client.
- Test your SOAP client.
Advanced configuration
This is a client implementation on top of php-soap. For more advanced configuration, you can check the documentation inside the php-soap packages.
Customize the code generation
Why this soap client was made
By default, the SoapClient works with a mix of arrays, stdClasses and other scalar types. This is not a good practice in a modern OOP world because:
- It makes your code hard to test.
- It breaks Code Completion
- It is hard to track changes in the response and request objects.
- The content of a result is never explicit.
To solve the above problems, this package will force you into using Value-objects for Requests and Responses. We know that maintaining these value-objects can be a load of work. No worries! There are some commandline tools available that will help you with generating a good base to start with. Because the SoapClient will need a classmap of WSDL to PHP Classes, there is also a classmap generator available. This will surely save you a lot of time! By adding SOAP type converters, it is possible to transform the values of a specific SOAP type from/to a PHP type. The package comes included with some basic transformers for date and datetime. On, top of that, it is very easy to create your own transformers.
Another problem is that the native SoapClient works with a lot of magic methods. It is hard to debug these magic methods hence there is no code completion. Both SOAP and implementation methods are on the same object.
This package will force you into wrapping a SoapClient into your own Client. You can choose to only expose the methods you need. It will always be clear to the developer what's in your client, how it works and what it returns. We even provided a base Client for you to use with some common used methods for debugging, authentication and an event system.
In lots of SOAP integrations, the logging, caching and Soap calls are in the same method. This makes your code hard to read and dependent on other classes / packages.
Creating a great OO SOAP client means that you'll have to create a lot of code. This can be a tedious task which can be automated. That is why we've added the tools to automatically generate the SOAP objects from the XSD scheme inside the WSDL. It is even possible to specify your own code-generation rules and code assemblers or use one of our many built-in classes.
It is important keep your code clean. Therefore, we added an event-listener to your Soap client. You can hook in at every important step of the SOAP flow. This way it is possible to add logging, validation and error handling with event subscribers. Pretty cool right?!
Implementing SOAP extensions is a real pain in the ass. It forces you to overwrite core methods of the built-in SOAP client. If you ever had to implement WSA or WSSE in SOAP, you know that there is something wrong in the core. Therefore, we made it easy for you to extend our SOAP client. You can specify which data transfer handler like e.g. Guzzle you want to use. Depending on the selected handler, you can easily add support for SOAP extensions or advanced authentication through HTTP middlewares.
Dealing with ext-soap is not for all developers. There are some nasty quirks you need to know about. Therefore, we made it possible for you to use which ever driver you want to use. By default we will still ship an ext-soap driver, but it is completely opt-in. You can use any user-land SoapClient implementation if you wrap it in our own driver interfaces.
Testing webservices is hard!
This package provide some various ways of testing a SOAP service.
Since the transport is HTTP based, you could use a php-vcr
implementation.
If you don't want to do actual HTTP calls, you could also use a custom Transport
or Caller
in your test cases.
Testing your SOAP client will be very fast and without any errors at the 3th party side of the integration.
Last but not least, we want to make it easy for you to configure your SoapClient. That is why we included a generated ClientFactory on which you can configure your custom Client. You want some other settings during development and in production? No problem! Sit back and let the factory handle your Client initialization.