jolicode / harvest-php-api

🌾 A Harvest API PHP Client
MIT License
22 stars 6 forks source link

Unexpected EOF for usage example #14

Closed bartiii closed 4 years ago

bartiii commented 4 years ago

Hey

I tried to run e.g. from https://github.com/jolicode/harvest-php-api#usage and I got # unable to fetch the response from the backend: unexpected EOF

In Symfony server console I see: Mar 15 17:16:29 |ERROR| SERVER issue with server callback error="unable to fetch the response from the backend: unexpected EOF"

My setup:

xavierlacot commented 4 years ago

I can not reproduce this bug.

composer.json:

{
    "require": {
        "jolicode/harvest-php-api": "3.0",
        "symfony/http-client": "^4.4",
        "nyholm/psr7": "^1.2"
    },
    "minimum-stability": "stable"
}

test.php:

<?php
require './vendor/autoload.php';

// $client contains all the methods to interact with the API
$client = JoliCode\Harvest\ClientFactory::create(
    '1234.XX.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
    '12345678'
);

$clients = $client->listClients([
    'is_active' => true,
]);

if (get_class($clients) !== 'JoliCode\Harvest\Api\Model\Error') {
    $clients = $clients->getClients();
}

var_dump($clients);

php test.php result (of course, with a valid token):

php test.php
object(JoliCode\Harvest\Api\Model\Clients)#40 (8) {
  ["clients":protected]=>
  array(6) {
    [0]=>
    object(JoliCode\Harvest\Api\Model\Client)#49 (8) {
      ["id":protected]=>
      ...
    }
  }
}
bartiii commented 4 years ago

Oh, it helped me a bit - I had known that it should work on my conf!

I tried to dig deeper and found that my php process is terminated with:

The process has been signaled with signal "11".

With this, I found this issue: https://github.com/symfony/symfony/issues/29341 I tried to set up opcache as described in a linked task but nothing happened so I removed my PHP 7.3.15 (installed from brew) and installed older one 7.2.28. It helped in my case.

Thanks!