Skip to content

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

@dkarlovi

Description

@dkarlovi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions