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

DiscoveryFailedException Slim Request Factory #190

Closed
NicoP-S opened this issue Oct 16, 2020 · 3 comments · Fixed by #192
Closed

DiscoveryFailedException Slim Request Factory #190

NicoP-S opened this issue Oct 16, 2020 · 3 comments · Fixed by #192

Comments

@NicoP-S
Copy link

NicoP-S commented Oct 16, 2020

PHP version: 7.3.23

Description

I am trying to get GitLabPHP/Client running with Slim Psr7 ( psr17 compliant ). It uses discovery.

The Docs say that slim framework should work:

A built-in strategy supporting the HTTPlug adapters, clients and factories (including Symfony, Guzzle, Diactoros and Slim Framework)

Error Message:

PHP Fatal error:  Uncaught Http\Discovery\Exception\DiscoveryFailedException: Could not find resource using any discovery strategy. Find more information at http://docs.php-http.org/en/latest/discovery.html#common-errors
 - Puli Factory is not available
 - No valid candidate found using strategy "Http\Discovery\Strategy\CommonClassesStrategy". We tested the following candidates: .
 - 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.

 in /tmp/gitlabtest/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41
Stack trace:
#0 /tmp/gitlabtest/vendor/php-http/discovery/src/ClassDiscovery.php(79): Http\Discovery\Exception\DiscoveryFailedException::create(Array)
#1 /tmp in /tmp/gitlabtest/vendor/php-http/discovery/src/Psr17FactoryDiscovery.php on line 22

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

I don't know if it is a problem of slimphp/Slim-Psr7 or this repo. Or maybe my setup?

How to reproduce

composer require m4tthumphrey/php-gitlab-api:^10.0 guzzlehttp/guzzle:^7.0.1 slim/slim slim/psr7

test.php:

<?php
include('vendor/autoload.php');
$client = new \Gitlab\Client();

Possible Solution

Additional context

GitLabPHP/Client#586

@NicoP-S
Copy link
Author

NicoP-S commented Oct 16, 2020

@webmaster777 like you said i checked the CommonPsr17ClassesStrategy.php
slimphp/Slim-Psr7#172 (comment)

It references

'Http\Factory\Slim\RequestFactory'
'Http\Factory\Slim\ResponseFactory'
'Http\Factory\Slim\ServerRequestFactory'
'Http\Factory\Slim\StreamFactory'
'Http\Factory\Slim\UploadedFileFactory'
'Http\Factory\Slim\UriFactory'

I think the namespace is not correct anymore. Correct would be Slim\Psr7\Factory\...
https://github.com/slimphp/Slim-Psr7/tree/master/src/Factory

Am i right? Sorry for asking.

@dbu
Copy link
Contributor

dbu commented Oct 21, 2020

are these Http\Factory\Slim* things a legacy thing and the current slim thing is Slim\Psr7\Factory*? if that is the case, it would be great if you can do a pull request to add the Slim\Psr7 classes in the appropriate places so that they can be discovered.

@webmaster777
Copy link
Contributor

I found the old repo for factories btw: https://github.com/http-interop/http-factory-slim It indeed predates the PSR-17 implementation of Slim.

In order to maintain BC we should only add the new Slim implementations, right?

webmaster777 added a commit to webmaster777/discovery that referenced this issue Oct 23, 2020
@dbu dbu closed this as completed in #192 Oct 26, 2020
dbu pushed a commit that referenced this issue Oct 26, 2020
* Add Slim's psr-17 factories

closes #190

* Added Slim disco to changelog
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 a pull request may close this issue.

3 participants