Skip to content

Add support for Guzzle 8 - #21

Open
jtojnar wants to merge 5 commits into
php-http:1.xfrom
jtojnar:guzzle8
Open

Add support for Guzzle 8#21
jtojnar wants to merge 5 commits into
php-http:1.xfrom
jtojnar:guzzle8

Conversation

@jtojnar

@jtojnar jtojnar commented Jul 22, 2026

Copy link
Copy Markdown
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
Documentation TBD
License MIT

What's in this PR?

Add support for Guzzle 8

This is a bit stricter but mostly compatible so not much reason to create a new project.

Changes affecting us involve improved type annotations and splitting out ResponseException.

https://github.com/guzzle/guzzle/releases/8.0.0

I also enable PHPStan on tests to increase certainty that it works.

Why?

Allows using HTTPlug with Guzzle 8.

Example Usage

Same as before, just install guzzlehttp/guzzle ^8.0.0

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)

To Do

  • More thorough testing

jtojnar added 5 commits July 22, 2026 11:46
We do not ignore any errors.

And it is better to specify it for individual errors with custom explanation for each.
If we introduce baseline, it should only contain universal errors.

https://phpstan.org/user-guide/baseline
It will allow us to make some exceptions conditional.
With Guzzle 8, `TooManyRedirectsException` extends `ResponseException`,
which expects a third `$response` parameter, making PHPStan fail with:

    Class GuzzleHttp\Exception\TooManyRedirectsException constructor invoked with 2 parameters, 3-4 required.

This also matches what Guzzle 7 itself does:
https://github.com/guzzle/guzzle/blob/7.10.0/src/RedirectMiddleware.php#L155
This will make it easier to notice discrepancies.

Had to add some ignores to suppress errors from differences between versions.
This is a bit stricter but mostly compatible so not much reason to create a new project.

Changes affecting us involve improved type annotations and splitting out `ResponseException`.

https://github.com/guzzle/guzzle/releases/8.0.0
@Chris53897

Copy link
Copy Markdown
Contributor

@jtojnar thanks for this PR. I guess CI needs to be adjusted to cover test-runs for version 7 and 8

But we should wait for a response from @dbu first, if a new package should be created, or support for guzzle 8 should be included in this package.

@dbu

dbu commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

the pattern we thought of (and documented) is that one requires just the adapter and gets the right version of guzzle. i think we should create a new repository.

however, the approach of separate repos seems weird to me now. i don't expect to have major versions of just the adapter. i think what i want to do is create just php-http/guzzle-adapter and have a branch 7.x and 8.x in there. and chosing the version is from chosing the desired adapter version.

then each adapter branch supports only one guzzle version and we have no need to if checks in the code. but can still fix things in the 7.x branch if needed and merge 7.x to 8.x to have fixes in both branches.

wdyt, does that sound good?

@jtojnar

jtojnar commented Jul 29, 2026

Copy link
Copy Markdown
Author

One potential issue I see is when we release a hypothetical httplug 3.0, we would need to have branches 7.x-for-3.x and 8.x-for-3.x.

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