1
0
mirror of synced 2024-11-25 06:46:07 +03:00
api-client-php/doc/customization/customization.md
2021-06-02 17:00:32 +03:00

1.6 KiB

Customization

Both ClientFactory and ClientBuilder provide the necessary functionality to replace PSR dependencies with any other compatible implementation. By default, those dependencies will be detected via service discovery. But service discovery supports a limited amount of implementation. If your implementation is not supported - the client won't work unless you provide the necessary dependencies manually. Another case would be testing. You can provide special HTTP client implementation which will return mocked responses instead of making real requests.

The Client uses chain of responsibility pattern to process requests. Each request and response is being processed by the pipeline of handlers. Every handler can apply some mutation to the request or response and can pass it to the next handler. In fact, API authentication is made possible by using a special handler which appends API key to every request.