Skip to content

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"
        }
    }
}

@github-actions
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