question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[REQ][PHP] depend on meta packages providing the HTTP implementation instead of directly on Guzzle

See original GitHub issue

Is your feature request related to a problem? Please describe.

Currently, the packages generated by php depend on Guzzle, like so

{
    "require": {
        "php": ">=7.2",
        "ext-curl": "*",
        "ext-json": "*",
        "ext-mbstring": "*",
        "guzzlehttp/guzzle": "^6.2"
    }
}

This is functional, but not ideal, making it harder to swap out HTTP clients, like for example Symfony HTTP Client if you’re using Symfony.

Being able to choose your desired HTTP client is very desirable in modern PHP apps since you might have existing clients already, setup to log requests via telemetry, use caching, etc.

Describe the solution you’d like

Instead of relying on Guzzle directly, depend on a psr/http-client-implementation (AKA PSR 18). This is a metapackage which implementations can declare they provide, all the major ones already do (including Guzzle, Symfony, etc).

Describe alternatives you’ve considered

Alternatively, the client implementation to select might be php-http/async-client-implementation (since the client is expected to be async). The offered implementations are fewer, but the major ones are still there. Result is the same: developer being able to inject their desired client.

This could also be done both ways: depend on the regular client, check if it’s one of the async ones at runtime and allow async ops if so.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:7
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rauanmayemircommented, Jun 9, 2021

Sorry, dropped the ball here. Feel free to start working on it yourself if it’s urgent.

1reaction
rauanmayemircommented, Apr 8, 2021

@dkarlovi It’s great that we’re on the same page. I also saw depending on http-factory-implementation as both correct way and lesser evil. As for the use of guzzle’s helper functions, I think it can be discarded in favor of PHP built-in functions. (guzzle mostly just wraps them anyway)

P.S: Planning to dig into it this weekend.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MetaPackages - Community Help Wiki
These packages do not contain actual software, they simply depend on other packages to be installed. This setup allows entire sets of software ......
Read more >
Packagist
The following packages provide psr/http-client-implementation ; Guzzle is a PHP HTTP client library. 438 045 606 ; Provides powerful methods to fetch HTTP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found