Swader / diffbot-php-client

[Deprecated - Maintenance mode - use APIs directly please!] The official Diffbot client library
MIT License
53 stars 20 forks source link

composer require swader/diffbot-php-client fails even after composer require php-http/guzzle6-adapter #37

Closed ankushdharkar closed 8 years ago

ankushdharkar commented 8 years ago

Running composer require php-http/guzzle6-adapter works. Adds an entry "php-http/guzzle6-adapter": "^0.1.0", into composer.json

Running composer require swader/diffbot-php-client fails with message :

Using version ^1.2 for swader/diffbot-php-client
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for swader/diffbot-php-client ^1.2 -> satisfiable by swader/diffbot-php-client[1.2].
    - swader/diffbot-php-client 1.2 requires php-http/client-implementation ^1.0 -> no matching package found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.
Swader commented 8 years ago

Everything should work if you first install the php-http/guzzle6-adapter with

composer require php-http/guzzle6-adapter

and only then pull in the PHP client with

composer require swader/diffbot-php-client

(no need to define versions)

This was done so that you can use any other HTTP client implementation and can avoid Guzzle if you prefer something else.

Please let me know if the above order doesn't immediately work.

ankushdharkar commented 8 years ago

I did exactly that. Didn't work

Swader commented 8 years ago

Ok, looking into it now. Thanks

ankushdharkar commented 8 years ago

Np. Maybe because I also installed the aws-sdk-php, it was a problem?

Swader commented 8 years ago

I doubt it. It could be that your minimum stability needs modifying. Could you try setting the minimum-stability flag of your composer.json file, either local or global, to "beta"?

ankushdharkar commented 8 years ago

Not sure what you suggest me to change. This is my current composer.json

{
    "require": {
        "aws/aws-sdk-php": "^3.11",
        "php-http/guzzle6-adapter": "^0.1.0"
    }
}
ankushdharkar commented 8 years ago

Do you want me to do this? :

{
    "require": {
        "aws/aws-sdk-php": "^3.11",
        "php-http/guzzle6-adapter": "^0.1.0@beta"
    }
}
Swader commented 8 years ago

Found the issue. The guzzle6-adapter still hasn't had its newest version tagged and pushed to packagist, so as it is, it provides adapter-implementation rather than client-implementation. A quick workaround is manually specifying the repo:

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/php-http/guzzle6-adapter"
        }
    ],

However, due to some internal shuffling in the php-http project and upcoming releases, that'll cause this error:

    - Installation request for php-http/utils ^0.1.0@dev -> satisfiable by php-http/utils[0.1.x-dev].
    - php-http/utils 0.1.x-dev requires php-http/message-factory ^0.4@dev -> no matching package found.

I'm in contact with the php-http team right now and working on resolving this. Should be done soon. Sorry about this, it happens when you try to be cutting edge.

ankushdharkar commented 8 years ago

All good. Thank you for looking into it.

ankushdharkar commented 8 years ago

Don't let these setbacks deter you from providing more cutting-edge stuff ;)

Swader commented 8 years ago

Heh, thanks :)

Ok, after some changes in the php-http project and minor alterations in this client's composer file, here's the solution:

Put the following into your composer.json file:

"minimum-stability": "dev",
"prefer-stable": true

If guzzle6-adapter is installed, remove it with

composer remove php-http/guzzle6-adapter

reinstall with

composer require php-http/guzzle6-adapter

This will install version 0.2@dev, which has the proper provides key.

Then, you can install the diffbot client:

composer require swader/diffbot-php-client

Let me know if it's okay.

Swader commented 8 years ago

@ankushdharkar any news?

ankushdharkar commented 8 years ago

Hi @Swader. Just installed it using the above method. It succeeded. Thank you.

Will update if there are issues. Closing it for now.

ankushdharkar commented 8 years ago

On doing a composer require php-http/guzzle6-adapter, I get a message saying Package php-http/client-tools is abandoned, you should avoid using it. Use php-http/client-common instead.

Anyway, I went ahead and used the new diffbot-php-client. It did not work and failed with fatal errors :

PHP Fatal error:  Uncaught exception 'Http\Discovery\NotFoundException' with message 'Not found' in <path>/Server/vendor/php-http/discovery/src/ClassDiscovery.php:52
Stack trace:
#0 <path>/Server/vendor/php-http/discovery/src/FactoryDiscovery.php(18): Http\Discovery\ClassDiscovery::find()
#1 <path>/Server/vendor/php-http/discovery/src/MessageFactoryDiscovery.php(49): Http\Discovery\FactoryDiscovery::find()
#2 <path>/Server/vendor/swader/diffbot-php-client/src/Diffbot.php(103): Http\Discovery\MessageFactoryDiscovery::find()
#3 <path>/Server/vendor/swader/diffbot-php-client/src/Diffbot.php(189): Swader\Diffbot\Diffbot->setHttpClient()
#4 <path>/ in <path>/Server/vendor/php-http/discovery/src/FactoryDiscovery.php on line 20

Fatal error: Uncaught exception 'Http\Discovery\NotFoundException' with message 'Not found' in <path>/Server/vendor/php-http/discovery/src/ClassDiscovery.php:52
Stack trace:
#0 <path>/Server/vendor/php-http/discovery/src/FactoryDiscovery.php(18): Http\Discovery\ClassDiscovery::find()
#1 <path>/Server/vendor/php-http/discovery/src/MessageFactoryDiscovery.php(49): Http\Discovery\FactoryDiscovery::find()
#2 <path>/Server/vendor/swader/diffbot-php-client/src/Diffbot.php(103): Http\Discovery\MessageFactoryDiscovery::find()
#3 <path>/Server/vendor/swader/diffbot-php-client/src/Diffbot.php(189): Swader\Diffbot\Diffbot->setHttpClient()
#4 <path>/ in <path>/Server/vendor/php-http/discovery/src/FactoryDiscovery.php on line 20

So, I moved back to "swader/diffbot-php-client":"^0.4.5" (without any php-http/guzzle6-adapter) in my composer.json

Swader commented 8 years ago

@ankushdharkar I have just released a much more stable version 2.0. Could you please test?

Swader commented 8 years ago

Fixed.

ankushdharkar commented 8 years ago

Hey @Swader. Sorry for the late reply.

I just installed 2.0. It doesn't work if I remove "minimum-stability": "dev", from my composer.json. Otherwise, it seems to be working fine. Thank you.

Swader commented 8 years ago

Yes I'm sorry about needing minimimum-stability lowered, it's required for now, at least until the depending packages are released as stable. Everything should work regardless, though.