Skip to content

[11.x] Support auto-discovery of PSR-17 implementations #53711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2024

Conversation

hafezdivandari
Copy link
Contributor

@hafezdivandari hafezdivandari commented Nov 29, 2024

The symfony/psr-http-message-bridge supports auto-detecting PSR-17 factories: symfony/symfony#51197

This PR adds support for php-http/discovery on Laravel, that allows auto-discovery of PSR-17 implementations.

You may refer to php-http/discovery readme for more info:

If you use a library/SDK that requires php-http/discovery, you can configure the auto-discovery mechanism to use a specific implementation when many are available in your project.

For example, if you have both nyholm/psr7 and guzzlehttp/guzzle in your project, you can enable the php-http/discovery composer plugin and configure it to use guzzlehttp/guzzle instead of nyholm/psr7 by running the following command:

composer config allow-plugins.php-http/discovery true
composer config extra.discovery.psr/http-factory-implementation GuzzleHttp\\Psr7\\HttpFactory

This will update your composer.json file to add the following configuration:

{
    "config": {
         "allow-plugins": {
             "php-http/discovery": true
        }
    },
    "extra": {
        "discovery": {
            "psr/http-factory-implementation": "GuzzleHttp\\Psr7\\HttpFactory"
        }
    }
}

Copy link

Thanks for submitting a PR!

Note that draft PR's are not reviewed. If you would like a review, please mark your pull request as ready for review in the GitHub user interface.

Pull requests that are abandoned in draft may be closed due to inactivity.

@hafezdivandari hafezdivandari changed the title [11.x] Support auto-discovery of psr-17 http factory implementation [11.x] Support auto-discovery of PSR-17 implementations Nov 29, 2024
@hafezdivandari hafezdivandari marked this pull request as ready for review November 29, 2024 20:10
@taylorotwell taylorotwell merged commit 682827f into laravel:11.x Nov 29, 2024
38 checks passed
@hafezdivandari hafezdivandari deleted the 11.x-psr-auto-discovery branch November 29, 2024 20:40
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.

2 participants