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

psr17 discorvery not working #172

Closed
NicoP-S opened this issue Oct 15, 2020 · 5 comments
Closed

psr17 discorvery not working #172

NicoP-S opened this issue Oct 15, 2020 · 5 comments

Comments

@NicoP-S
Copy link

NicoP-S commented Oct 15, 2020

Hi,
i am trying to get slim psr-7 running in an project where https://github.com/php-http/discovery is used. But I get following error.

{
    "message": "Slim Application Error",
    "exception": [
        {
            "type": "Http\\Discovery\\Exception\\NotFoundException",
            "code": 0,
            "message": "No PSR-17 request factory found. Install a package from this list: https://packagist.org/providers/psr/http-factory-implementation",
            "file": "/srv/www/clients/client1/web52/web/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php",
            "line": 22
        },
        {
            "type": "Http\\Discovery\\Exception\\DiscoveryFailedException",
            "code": 0,
            "message": "Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors\n - Puli Factory is not available\n - No valid candidate found using strategy \"Http\\Discovery\\Strategy\\CommonClassesStrategy\". We tested the following candidates: .\n - No valid candidate found using strategy \"Http\\Discovery\\Strategy\\CommonPsr17ClassesStrategy\". We tested the following candidates: Phalcon\\Http\\Message\\RequestFactory, Nyholm\\Psr7\\Factory\\Psr17Factory, Zend\\Diactoros\\RequestFactory, GuzzleHttp\\Psr7\\HttpFactory, Http\\Factory\\Diactoros\\RequestFactory, Http\\Factory\\Guzzle\\RequestFactory, Http\\Factory\\Slim\\RequestFactory, Laminas\\Diactoros\\RequestFactory.\n\n",
            "file": "/srv/www/clients/client1/web52/web/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php",
            "line": 41
        }
    ]
}

It tests for Http\Factory\Slim\RequestFactory.
I have checked my vendor dir. I only have Slim\Psr7\Factory\RequestFactory

Am I doing something wrong ?
Or is this a bug in one of slim/psr7 or php-http/discovery ?

@webmaster777
Copy link
Contributor

Meh, it's not a bug. The factories in this repo are just not in any of the default strategies (e.g. CommonClassesStrategy)

The factories it does look for are in an other repo (https://github.com/slimphp/Slim-Http). However, you should be able to configure your container to use the factories in this repo.

@webmaster777
Copy link
Contributor

You could also provide your own strategy to resolve into the classes in this repo, or send a PR to php-http/discovery to add these classes to the CommonClassesStrategy

@webmaster777
Copy link
Contributor

ref: GitLabPHP/Client#586

@NicoP-S
Copy link
Author

NicoP-S commented Oct 16, 2020

I also tried with slim/http but it gives the same error.

$ composer require slim/http

I will go the way you mentioned
GitLabPHP/Client#586 (comment)

$builder = new Gitlab\HttpClient\Builder(
null, // PSR-18 client autodetect
new Slim\Psr7\Factory\RequestFactory(),
new Slim\Psr7\Factory\StreamFactory(),
new Slim\Psr7\Factory\UriFactory()
);

$client = new Gitlab\Client($builder);

Thanks for your help!

@NicoP-S NicoP-S closed this as completed Oct 16, 2020
@webmaster777
Copy link
Contributor

I also tried with slim/http but it gives the same error.


$ composer require slim/http

Makes sense, slim/http only decorates the classes, it does not provide actual psr-7 or psr-17 implementation itself I think.

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

2 participants