feat: add support for Guzzle 8 #9377
Draft
GrahamCampbell wants to merge 1 commit into
Draft
Conversation
This was referenced Jul 21, 2026
GrahamCampbell
marked this pull request as draft
July 21, 2026 22:21
bshaffer
reviewed
Jul 21, 2026
| $res = $ex->getResponse(); | ||
| // Guzzle 7 carries the response on RequestException, Guzzle 8 only on | ||
| // its ResponseException subclass, hence the method_exists() check. | ||
| $res = method_exists($ex, 'getResponse') ? $ex->getResponse() : null; |
Contributor
There was a problem hiding this comment.
Is there no way to use instanceof here instead using the appropriate subclass? Using method_exists seems a little hacky
Contributor
Author
There was a problem hiding this comment.
No, because of the need to keep Guzzle 7 support. Guzzle 7 has RequestException and Guzzle 8 and both RequestException and ResponseException. RequestException in Guzzle 7 has getResponse, but only ResponseException in Guzzle 8 has getResponse. After dropping Guzzle 7 at some point in the future, this can be replaced with an instanceof ResponseException
Guzzle 7.x uses this hierarchy:
. \RuntimeException
└── TransferException (implements GuzzleException)
├── ConnectException (implements NetworkExceptionInterface)
└── RequestException (implements RequestExceptionInterface)
├── BadResponseException
│ ├── ClientException
│ └── ServerException
└── TooManyRedirectsException
Guzzle 8.0 uses this hierarchy:
. \RuntimeException
└── TransferException (implements GuzzleException)
├── HandlerClosedException
├── NetworkException (implements NetworkExceptionInterface)
│ ├── ConnectException
│ │ └── ConnectTimeoutException
│ └── NetworkTimeoutException
└── RequestException (implements RequestExceptionInterface)
└── ResponseException
├── BadResponseException
│ ├── ClientException
│ └── ServerException
├── ResponseTransferException
│ └── ResponseTimeoutException
└── TooManyRedirectsException
Signed-off-by: Graham Campbell <hello@gjcampbell.co.uk>
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.
Guzzle 8.0.0 was released on July 20th. Lots of people want to use it, and thus popular packages in the ecosystem like this one need to be updated to support it, so here I am, adding support. :)