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

Cannot install (problem with composer on PHP 7.2) #20

Closed
kylelondonuk opened this issue Mar 25, 2019 · 13 comments
Closed

Cannot install (problem with composer on PHP 7.2) #20

kylelondonuk opened this issue Mar 25, 2019 · 13 comments

Comments

@kylelondonuk
Copy link

Hi, I tried running your suggested composer commands, but when I open vendor/autoload.php, I get this:

[25-Mar-2019 18:10:12 UTC] 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: Nyholm\Psr7\Factory\Psr17Factory, Zend\Diactoros\ResponseFactory, Http\Factory\Diactoros\ResponseFactory, Http\Factory\Guzzle\ResponseFactory, Http\Factory\Slim\ResponseFactory.

 in /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/Exception/DiscoveryFailedException.php:41
Stack trace:
#0 /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/ClassDiscovery.php(79): Http\Discovery\Exception\DiscoveryFailedException::create(Array)
#1 /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/Psr17Factory in /home/mgtckfyeswfr/apis/slack/vendor/php-http/discovery/src/ClassDiscovery.php on line 210

I am running PHP 7.2. I looked at this link: http://docs.php-http.org/en/latest/discovery.html#common-errors and tried installing all the packages it mentions, but when I try the Puli install:

composer require puli/composer-plugin

i get this:

[InvalidArgumentException]                    
  Could not find package puli/composer-plugin.  
                                                
  Did you mean this?                            
      puli/composer-plugin

it looks like a full stop is somehow being added to the end of the word plugin?

Can you help?

@pyrech
Copy link
Member

pyrech commented Mar 25, 2019

Hum, it looks like php-http fails to find a suitable factory for http messages. And I'm pretty sure Puli is not the best option for you.
Did you run the command compose composer require php-http/curl-client guzzlehttp/psr7? What was the output? It should have install the factories from Guzzle.

@kylelondonuk
Copy link
Author

Hi - thanks for such a quick response! Yes I ran that command and it all seemed fine. it suggested installing a few more at the end, but no errors... here it is:

Using version ^2.0 for php-http/curl-client
Using version ^1.5 for guzzlehttp/psr7
./composer.json has been created
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 13 installs, 0 updates, 0 removals
  - Installing symfony/options-resolver (v4.2.4): Loading from cache
  - Installing psr/http-message (1.0.1): Loading from cache
  - Installing psr/http-factory (1.0.0): Loading from cache
  - Installing psr/http-client (1.0.0): Loading from cache
  - Installing clue/stream-filter (v1.4.0): Loading from cache
  - Installing php-http/message-factory (v1.0.2): Loading from cache
  - Installing php-http/message (1.7.2): Loading from cache
  - Installing php-http/promise (v1.0.0): Loading from cache
  - Installing php-http/httplug (v2.0.0): Loading from cache
  - Installing php-http/discovery (1.6.1): Loading from cache
  - Installing php-http/curl-client (2.0.0): Loading from cache
  - Installing ralouphie/getallheaders (2.0.5): Loading from cache
  - Installing guzzlehttp/psr7 (1.5.2): Loading from cache
php-http/message suggests installing zendframework/zend-diactoros (Used with Diactoros Factories)
php-http/message suggests installing slim/slim (Used with Slim Framework PSR-7 implementation)
php-http/discovery suggests installing puli/composer-plugin (Sets up Puli which is recommended for Discovery to work. Check http://docs.php-http.org/en/latest/discovery.html for more details.)

and then the jolicode also seems fine:

Using version ^1.1 for jolicode/slack-php-api
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 17 installs, 0 updates, 0 removals
  - Installing php-http/client-common (2.0.0): Loading from cache
  - Installing php-http/multipart-stream-builder (1.0.0): Loading from cache
  - Installing symfony/polyfill-ctype (v1.11.0): Loading from cache
  - Installing symfony/yaml (v4.2.4): Loading from cache
  - Installing symfony/serializer (v4.2.4): Loading from cache
  - Installing php-jsonpointer/php-jsonpointer (v3.0.2): Loading from cache
  - Installing league/uri-parser (1.4.1): Loading from cache
  - Installing league/uri-interfaces (1.1.1): Loading from cache
  - Installing league/uri-schemes (1.2.1): Loading from cache
  - Installing psr/simple-cache (1.0.1): Loading from cache
  - Installing league/uri-hostname-parser (1.1.1): Loading from cache
  - Installing league/uri-components (1.8.2): Loading from cache
  - Installing league/uri-manipulations (1.5.0): Loading from cache
  - Installing jane-php/json-schema-runtime (v4.2.0): Loading from cache
  - Installing jane-php/open-api-runtime (v4.2.0): Loading from cache
  - Installing jolicode/slack-php-api (1.1.3): Loading from cache
php-http/client-common suggests installing php-http/logger-plugin (PSR-3 Logger plugin)
php-http/client-common suggests installing php-http/cache-plugin (PSR-6 Cache plugin)
php-http/client-common suggests installing php-http/stopwatch-plugin (Symfony Stopwatch plugin)
symfony/yaml suggests installing symfony/console (For validating YAML files using the lint command)
symfony/serializer suggests installing psr/cache-implementation (For using the metadata cache.)
symfony/serializer suggests installing symfony/property-info (To deserialize relations.)
symfony/serializer suggests installing symfony/config (For using the XML mapping loader.)
symfony/serializer suggests installing symfony/property-access (For using the ObjectNormalizer.)
symfony/serializer suggests installing symfony/http-foundation (To use the DataUriNormalizer.)
symfony/serializer suggests installing doctrine/annotations (For using the annotation mapping. You will also need doctrine/cache.)
symfony/serializer suggests installing doctrine/cache (For using the default cached annotation reader and metadata cache.)
league/uri-hostname-parser suggests installing psr/simple-cache-implementation (To enable using other cache providers)
Writing lock file
Generating autoload files

@kylelondonuk
Copy link
Author

And then I run this with my token, which is where the error comes:

$client = JoliCode\Slack\ClientFactory::create($yourToken);

@kylelondonuk
Copy link
Author

And if it helps, here's the composer.json file:

"require": {
        "php-http/curl-client": "^2.0",
        "guzzlehttp/psr7": "^1.5",
        "jolicode/slack-php-api": "^1.1"
    }

@kylelondonuk
Copy link
Author

Ah, i did

composer require zendframework/zend-diactoros

and that worked - was the problem just that guzzle wasn't installing the discovery factories for me?

@pyrech
Copy link
Member

pyrech commented Mar 26, 2019

This behavior is quite strange because, as far as I know, zendframework/zend-diactoros & guzzlehttp/psr7 are equivalent libraries providing both PSR-7 implementations. They should work similarly. I do not really understand why guzzle's one is not detected correctly by the CommonClassesStrategy discovery 😕

I would say if Zend Diactoros works for you, just go ahead with it and remove guzzlehttp/psr7 😉

@vmunich
Copy link

vmunich commented Mar 29, 2019

I was having this when using guzzlehttp/psr7:

Http/Discovery/Exception/ClassInstantiationFailedException with message 'Unexpected exception when instantiating class.'

However, it works as expected when I install zendframework/zend-diactoros instead.

@damienalexandre
Copy link
Member

Confirmed, the installation steps are broken. I'm going to take a deeper look at it.

@pawelkmpt
Copy link

It also fails for me. I tried to install puli/composer-plugin as suggested in http://docs.php-http.org/en/latest/discovery.html#puli-factory-is-not-available but failed as well.

composer require puli/composer-plugin
                                                                                                                                                                                     
  [InvalidArgumentException]                                                                                                                                                         
  Could not find a version of package puli/composer-plugin matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability. 

Defining version of that package also fails as one of its dependencies doesn't meet minimum stability condition. Basically chain reaction of errors.

@damienalexandre
Copy link
Member

As a quick fix you can just force this package to version 1.x, the new 2.x version seams to be the problem:

"php-http/curl-client": "^1.0",

@damienalexandre
Copy link
Member

Just updated the documentation. Please do not use curl-client 2.0, I have no idea why it does not found the client.

composer require php-http/curl-client:"^1.7" guzzlehttp/psr7

@pawelkmpt
Copy link

composer require php-http/curl-client:"^1.7" guzzlehttp/psr7

it works! thanks!

@pyrech
Copy link
Member

pyrech commented Oct 3, 2019

Closing as this issue is fixed now. Please feel free to submit a new issue if someone face again a similar error 🙂

@pyrech pyrech closed this as completed Oct 3, 2019
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

5 participants