Skip to content

feat: add PSR-18/PSR-17 HTTP client injection support#127

Open
cb-alish wants to merge 1 commit intomasterfrom
psr/httpClient
Open

feat: add PSR-18/PSR-17 HTTP client injection support#127
cb-alish wants to merge 1 commit intomasterfrom
psr/httpClient

Conversation

@cb-alish
Copy link
Collaborator

Allow injecting a PSR-18 ClientInterface directly into ChargebeeClient without implementing the Chargebee-specific HttpClientFactory interface. PSR-17 request/stream factories can optionally be provided; when omitted, php-http/discovery auto-discovers any installed implementation.

New: src/HttpClient/PsrClientAdapter.php wraps a PSR-18 client and builds PSR-7 requests using injected or discovered PSR-17 factories.

The existing HttpClientFactory injection path and the default GuzzleFactory are unchanged — fully backward compatible.

New dependencies (require):

  • php-http/discovery ^1.0
  • psr/http-factory ^1.0

Include any additional information that might be helpful in reviewing the changes introduced by this pull request.

Allow injecting a PSR-18 ClientInterface directly into ChargebeeClient
without implementing the Chargebee-specific HttpClientFactory interface.
PSR-17 request/stream factories can optionally be provided; when omitted,
php-http/discovery auto-discovers any installed implementation.

New: src/HttpClient/PsrClientAdapter.php wraps a PSR-18 client and builds
PSR-7 requests using injected or discovered PSR-17 factories.

The existing HttpClientFactory injection path and the default GuzzleFactory
are unchanged — fully backward compatible.

New dependencies (require):
  - php-http/discovery ^1.0
  - psr/http-factory ^1.0

Note: guzzlehttp/guzzle remains in require for v4.x compatibility.
Removing it is deferred to the next major version.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy link

@ychedemois ychedemois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works just great, and lets me get rid of my custom HttPlugFactory class, that was largely a copy/paste of the GuzzleFactory provided in the SDK

😍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants