[Server] Add PSR-17 factory auto-discovery to StreamableHttpTransport #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces PSR-17 factory auto-discovery to the
StreamableHttpTransport, simplifying HTTP transport initialization by automatically discoveringResponseFactoryandStreamFactoryimplementations.Motivation & Context
The original implementation required developers to manually create and pass PSR-17 factory instances, adding unnecessary boilerplate to every HTTP transport usage. This was particularly cumbersome in simple use cases and examples where the choice of PSR-7 implementation wasn't critical. By implementing auto-discovery, we can provide a much cleaner API while still allowing explicit factory injection when needed.
What's Changed
php-http/discoverydependency for PSR-17 factory discoveryResponseFactoryandStreamFactoryconstructor parameters optional with fallback to auto discoveryPsr17Factory(fromphp-http/discovery)php-http/discoveryBreaking Changes
None. Existing code continues to work unchanged, and the simplified API is opt-in.