Fix: Clarify HTTP client variable in factory example#132
Merged
Plytas merged 3 commits intoJul 11, 2025
Conversation
The example in the README was using an undefined $client variable within the withStreamHandler method. This change explicitly defines the $client variable when configuring withHttpClient to make the example clearer and prevent potential confusion.
Collaborator
|
Thanks! But maybe we could use a different name for the variable like |
Collaborator
|
Also to note. You might not need the Lines 146 to 148 in 84ffe3d |
Renamed the HTTP client variable from $client to $guzzleClient to avoid confusion with the Gemini client instance and make the code example more explicit about which client is being referenced.
Added a timeout configuration to the Guzzle client example to demonstrate best practices for HTTP client configuration. This helps users understand how to configure client options properly.
Plytas
approved these changes
Jul 11, 2025
Contributor
Author
|
@Plytas I've improved the example by renaming the variable to ->withHttpClient($guzzleClient = new \GuzzleHttp\Client(['timeout' => 30])) // default: HTTP client found using PSR-18 HTTP Client Discovery
->withStreamHandler(fn(RequestInterface $request): ResponseInterface => $guzzleClient->send($request, [
'stream' => true // Allows to provide a custom stream handler for the http client.
])) |
Collaborator
|
Awesome, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
$clientvariable reference in README factory exampleDescription
The README example for configuring the Gemini client factory contained a reference to an undefined
$clientvariable within thewithStreamHandlermethod. This change explicitly defines the$clientvariable when configuringwithHttpClientto make the example clearer and prevent potential confusion for users.Changes
$client = new \GuzzleHttp\Client([])in thewithHttpClientmethod callTest plan
This is a documentation-only change that improves the code example's clarity.