Swader / diffbot-php-client

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

Fatal error: Puli Factory class does not exist #49

Closed tegansnyder closed 8 years ago

tegansnyder commented 8 years ago

I'm able to install this client by composer; however, when I attempt to call the CrawlBot API I get an error. Here is my code:

require '/vendor/autoload.php';

use Swader\Diffbot\Diffbot;

$diffbot = new Diffbot('my_token');
$crawl = $diffbot->crawl('SomeSite');
$job = $crawl->call();

var_dump($job->getDownloadUrl("json"));

Here is the error that is returned:

PHP Fatal error:  Uncaught RuntimeException: Puli Factory class does not exist in /app/vendor/php-http/discovery/src/ClassDiscovery.php:38
Stack trace:
#0 /app/vendor/php-http/discovery/src/ClassDiscovery.php(79): Http\Discovery\ClassDiscovery::getPuliFactory()
#1 /app/vendor/php-http/discovery/src/ClassDiscovery.php(99): Http\Discovery\ClassDiscovery::getPuliDiscovery()
#2 /app/vendor/php-http/discovery/src/HttpClientDiscovery.php(21): Http\Discovery\ClassDiscovery::findOneByType('Http\\Client\\Htt...')
#3 /app/vendor/swader/diffbot-php-client/src/Diffbot.php(102): Http\Discovery\HttpClientDiscovery::find()
#4 /app/vendor/swader/diffbot-php-client/src/Diffbot.php(268): Swader\Diffbot\Diffbot->setHttpClient()
#5 /private/var/www/sov/shell/get_diffbot_data.php(17): Swader\Diffbot\Diffbot->crawl('SomeSiteName')
#6 {main}
  thrown in /app/vendor/php-http/discovery/src/ClassDiscovery.php on line 38

My composer.json contains:

{
    "minimum-stability": "dev",
    "prefer-stable": true,
    "require": {
        "php-http/guzzle6-adapter": "~1.0",
        "php-http/message": "^1.2",
        "php-http/discovery": "~0.8.0",
        "puli/cli": "~1.0",
        "php-http/plugins": "~1.0",
        "puli/composer-plugin":"^1.0",
        "swader/diffbot-php-client": "^2.1@dev"
    }
}

I'm wondering if there is an issue upstream somewhere. Ideas?

jonathantullett commented 8 years ago

I'm also having the same issue. I've tried with the latest php-http/guzzle6-adapter (1.1) and stable (2.0) version of the Diffbot client.

tegansnyder commented 8 years ago

I tried with stable too. Same issue.

jonathantullett commented 8 years ago

@Swader - any thoughts on this one?

Swader commented 8 years ago

That's interesting. I cannot reproduce this. I used your exact composer.json and your exact test code (replaced with my token and my job name), but no dice, works just fine. Investigating further...

Swader commented 8 years ago

Successfully reproduced - tested on wrong VM which already had Puli globally installed.

sagikazarmark commented 8 years ago

Hi everyone,

We recently invested some work in improving our discovery strategies. As part of that, we removed the hard dependency on Puli.

So if you don't want to use Puli, just remove the composer plugin and update the php-http/discovery dependency to ^1.0. It comes with a few clients built-in (official httplug ones). For custom ones you can write custom discovery strategies or use Puli. Please refer to the documentation or ask us on slack.

If you want to use Puli: unfortunately there are many points where Puli might go wrong. Can you please check the composer install log and see that the puli build command ran fine (also you could run it manually: puli build)? You might need to download the puli.phar into your project root (although discovery comes with one). Also, please check to update your global puli binary to the latest if you have any.

There is also an autoloading problem with composer >= 1.0 && PHP >= 5.6: https://github.com/puli/issues/issues/190

Unfortunately the fix has not been merged yet.

Swader commented 8 years ago

Okay, initiating surgical removal of Puli from all parts of the client, thanks @sagikazarmark

Swader commented 8 years ago

@jonathantullett @tegansnyder

Sorry about the delay in getting this fixed guys, I have now removed Puli and updated dependencies, should all work.

tegansnyder commented 8 years ago

Thanks for fixing this. I appreciate it.

On Thursday, July 21, 2016, Bruno Škvorc notifications@github.com wrote:

@jonathantullett https://github.com/jonathantullett @tegansnyder https://github.com/tegansnyder

Sorry about the delay in getting this fixed guys, I have now removed Puli and updated dependencies, should all work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Swader/diffbot-php-client/issues/49#issuecomment-234191554, or mute the thread https://github.com/notifications/unsubscribe-auth/ABJQQyAEJXM_V_zSISWyORY0mKRYWv3Xks5qXy_GgaJpZM4JGZoe .

Tegan Snyder

jonathantullett commented 8 years ago

I've done a fresh 'composer require Swader/diffbot-php-client' and it's still pulling in Puli:

jbookpro:core-code tullettj$ composer require Swader/diffbot-php-client
Using version ^2.0 for Swader/diffbot-php-client
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
[...]
  - Installing ramsey/uuid (2.9.0)
    Downloading: 100%

  - Installing puli/discovery (1.0.0-beta9)
    Loading from cache

  - Installing puli/repository (1.0.0-beta10)
    Loading from cache

  - Installing puli/url-generator (1.0.0-beta4)
    Loading from cache

  - Installing puli/composer-plugin (1.0.0-beta10)
    Downloading: 100%

And then it fails at runtime with PHP Fatal error: Uncaught RuntimeException: Puli Factory class does not exist

Any suggestions, @Swader? I'm sure I'm missing something simple... :)

Thanks!

Swader commented 8 years ago

Ah, I forgot to tag a new release, very sorry! Try again please!

jonathantullett commented 8 years ago

We have lift off! (and the install looks a lot cleaner too!)

Thank you very much :)

Swader commented 8 years ago

Glad it works now :) Sorry it took a while, been swamped, hopefully can update further soon, lots of new features coming