guzzle / guzzle-services

Provides an implementation of the Guzzle Command library that uses Guzzle service descriptions to describe web services, serialize requests, and parse responses into easy to use model structures.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compatibility problem with PHP7.0 ?

2ndGAB opened this issue · comments

commented

Hello,
I recently installed your module which perfectly works with PHP5.6 on a new server running PHP7.0.
And with the exact same set of datas, it causes an error with JSON objects:

2016-10-23 09:37:17 Warning: Headers already sent in /var/www/mySite/vendor/cakephp/cakephp/src/basics.php:98
2016-10-23 09:37:17 Error: [GuzzleHttp\Command\Exception\CommandException] Error executing command: Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON
Request URL: /Imports/processImport/917944
Client IP: 88.13.16.12
Stack Trace:
#0 /var/www/mySite/vendor/guzzlehttp/command/src/AbstractClient.php(275): GuzzleHttp\Command\AbstractClient->createCommandException(Object(GuzzleHttp\Command\CommandTransaction))
#1 /var/www/mySite/vendor/guzzlehttp/command/src/AbstractClient.php(255): GuzzleHttp\Command\AbstractClient->emitProcess(Object(GuzzleHttp\Command\CommandTransaction))
#2 /var/www/mySite/vendor/guzzlehttp/guzzle/src/Event/Emitter.php(108): GuzzleHttp\Command\AbstractClient->GuzzleHttp\Command\{closure}(Object(GuzzleHttp\Event\EndEvent), 'end')
#3 /var/www/mySite/vendor/guzzlehttp/guzzle/src/RequestFsm.php(140): GuzzleHttp\Event\Emitter->emit('end', Object(GuzzleHttp\Event\EndEvent))
#4 /var/www/mySite/vendor/guzzlehttp/guzzle/src/RequestFsm.php(132): GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction))
#5 /var/www/mySite/vendor/react/promise/src/FulfilledPromise.php(25): GuzzleHttp\RequestFsm->GuzzleHttp\{closure}(Array)
#6 /var/www/mySite/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(Object(Closure), NULL, NULL)
#7 /var/www/mySite/vendor/guzzlehttp/guzzle/src/Message/FutureResponse.php(43): GuzzleHttp\Ring\Future\CompletedFutureValue->then(Object(Closure), NULL, NULL)
#8 /var/www/mySite/vendor/guzzlehttp/guzzle/src/RequestFsm.php(134): GuzzleHttp\Message\FutureResponse::proxy(Object(GuzzleHttp\Ring\Future\CompletedFutureArray), Object(Closure))
#9 /var/www/mySite/vendor/guzzlehttp/guzzle/src/Client.php(165): GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction))
#10 /var/www/mySite/vendor/guzzlehttp/command/src/AbstractClient.php(88): GuzzleHttp\Client->send(Object(GuzzleHttp\Message\Request))
#11 /var/www/mySite/vendor/guzzlehttp/command/src/AbstractClient.php(74): GuzzleHttp\Command\AbstractClient->execute(Object(GuzzleHttp\Command\Command))
#12 /var/www/mySite/vendor/s-tourisme/s-api-php/src/s/ApiClient/Client.php(247): GuzzleHttp\Command\AbstractClient->__call('confirmExport', Array)
#13 /var/www/mySite/src/Controller/sImportsController.php(454): s\ApiClient\Client->__call('confirmExport', Array)
#14 [internal function]: App\Controller\sImportsController->processimport('917944')
#15 /var/www/mySite/vendor/cakephp/cakephp/src/Controller/Controller.php(435): call_user_func_array(Array, Array)
#16 /var/www/mySite/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(122): Cake\Controller\Controller->invokeAction()
#17 /var/www/mySite/vendor/cakephp/cakephp/src/Http/ActionDispatcher.php(96): Cake\Http\ActionDispatcher->_invoke(Object(App\Controller\sImportsController))
#18 /var/www/mySite/vendor/cakephp/cakephp/src/Routing/Dispatcher.php(60): Cake\Http\ActionDispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#19 /var/www/mySite/webroot/index.php(37): Cake\Routing\Dispatcher->dispatch(Object(Cake\Network\Request), Object(Cake\Network\Response))
#20 {main}

Any idea?

Can you to checkout PR #109, which uses Guzzle6 internally and should be compatible with PHP70. Does the error persists?

commented

Hello @Konafets,
Are you talking about guzzlehttp-services?
So do I have to specify "guzzlehttp/guzzle-services": "0.6.*" in my composer.json?

Hi,

Are you talking about guzzlehttp-services?
Yes.

Some background: The master branch of this repo defines Guzzle5 as a dependency (via GuzzleCommand). But none of these libs are compatible with PHP70, but Guzzle6 is. Unfortunately the master of GuzzleServices is not compatible with Guzzle6 but #109 fix this. See #89 for the whole discussion.

So do I have to specify "guzzlehttp/guzzle-services": "0.6.*" in my composer.json?

Unfortunately you can not use composer in this way here. You need to clone this repo via git and then apply the PR on this repo.

$ git clone git@github.com:guzzle/guzzle-services.git
$ git fetch origin pull/109/head:guzzle6-pr
$ git checkout guzzle6-pr
$ composer install
$ vendor/phpunit/phpunit/phpunit

This is just a workaround till we merge it with master and release a new version.

commented

I fighted a bit with dependencies to be able to install guzzle, guzzle-services and guzzle-command which are depending on other module, along with some other ones....
I finally got everything.
Unfortunately, it's not so easy to migrate to guzzle 6 as Event class desappeared so that suppose to modify the topmost module using guzzlehttp.
So, I have to see that with the developper.... :-/

But that means that I cannot execute the code and see if the JSON Error is over.

You have to migrate your code to Guzzle6 as well. If you provide the code, maybe I can give you some hints. This would also an opportunity to collect some code snippets for a migration guide to help other devs.

commented

@Konafets, I would have liked but as I'm not the code owner, I afraid to not be able to do that...

I will close the issue. Please update your environment to use version 1.0.0 of this library. If your problem still exists, feel free to reopen the issue.

commented

@Konafets ok, thanks a lot