Skip to content
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

No PSR-17 stream factory found, but I have one installed #285

Closed
ErMaqui opened this issue Apr 2, 2021 · 4 comments
Closed

No PSR-17 stream factory found, but I have one installed #285

ErMaqui opened this issue Apr 2, 2021 · 4 comments

Comments

@ErMaqui
Copy link

ErMaqui commented Apr 2, 2021

PHP version: 7.4.11

Description
No PSR-17 stream factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation

How to reproduce
I've installed on a package composer. My composer.json file are:

{
  "require": {
    "sentry/sentry": ">= 3.0",
    "php-http/curl-client": "dev-master"
  },
  "config": {
    "vendor-dir": "packages"
  }
}

(I have installed guzzlehttp/psr7 through dependencies).

On composer.lock, I can find this (I've deleted some lines):

        {
            "name": "guzzlehttp/psr7",
            "version": "1.8.1",
            "require": {
                "php": ">=5.4.0",
                "psr/http-message": "~1.0",
                "ralouphie/getallheaders": "^2.0.5 || ^3.0.0"
            },
            "provide": {
                "psr/http-message-implementation": "1.0"
            },
            "require-dev": {
                "ext-zlib": "*",
                "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.8 || ^9.3.10"
            },
            "type": "library",
            "extra": {
                "branch-alias": {
                    "dev-master": "1.7-dev"
                }
            },
            "autoload": {
                "psr-4": {
                    "GuzzleHttp\\Psr7\\": "src/"
                },
                "files": [
                    "src/functions_include.php"
                ]
            },
            "description": "PSR-7 message implementation that also provides common utility methods",
            "time": "2021-03-21T16:25:00+00:00"
        },

On my code, I'm using:

require_once 'packages/autoload.php';

Can anyone help me with this problem?

@dbu
Copy link
Contributor

dbu commented Apr 3, 2021

the exception you get is about a missing stream factory. looking at the strategy code, i see that the candidates are:

        StreamFactory::class => [
            ['class' => NyholmHttplugFactory::class, 'condition' => [NyholmHttplugFactory::class]],
            ['class' => GuzzleStreamFactory::class, 'condition' => [GuzzleRequest::class, GuzzleStreamFactory::class]],
            ['class' => DiactorosStreamFactory::class, 'condition' => [DiactorosRequest::class, DiactorosStreamFactory::class]],
            ['class' => SlimStreamFactory::class, 'condition' => [SlimRequest::class, SlimStreamFactory::class]],

i think you need to require one of the above, e.g. nyholm/psr7. can you try that?

i wonder if php-http/curl-client should require psr/http-factory-implementation? what do you think, @Nyholm ? if none is passed, the client tries to find one and will simply fail if there is none available: https://github.com/php-http/curl-client/blob/master/src/Client.php#L85 . it seems to me we can safely assume that all implementers of the Psr\StreamFactoryInterface will have their package provide psr/http-factory-implementation.

@Nyholm
Copy link
Member

Nyholm commented Apr 3, 2021

Yeah, I think that make sense 👍

@dbu
Copy link
Contributor

dbu commented Apr 3, 2021

see php-http/curl-client#75

@dbu
Copy link
Contributor

dbu commented Apr 28, 2023

merged the fix

@dbu dbu closed this as completed Apr 28, 2023
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

No branches or pull requests

3 participants