-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
no more json() method for responses? #1106
Comments
No. It's because of psr7. |
Ok, thanks. |
Well, technically it does. Guzzle aims to be an implementation of psr7, allowing you to swap it out of anything else psr7, which is the entire point of psr7. If we stared adding methods, the value of implementing psr7 is lost. |
Ok, thank you 😢 |
I don't understand (sorry if it's a time lost for you, I'm trying to understand). In (sorry if I misunderstood something, or if my argumentation is unclear) |
Guzzle has switched over to PSR-7 only interfaces. In order to keep some of the old methods on responses like Furthermore, the |
Ok thanks for your answer! |
The Monolog example demonstrates the problem. If you would use a PSR-3 logger implementation, you could NOT use the If you want to have an easily available |
Sorry to dig up an old post, but I just ran across this very issue. Google results showed old documentation of the Out of curiosity, this seems to be more of a design philosophy question. I would expect PSR-7 compatible classes to implement all required methods of the interface (it's hardly an interface otherwise, no?). However, implementing additional/custom interfaces shouldn't inherently violate PSR-7. It does add a concrete dependency of the consuming application on the extended interface, yes, but AFAIK that doesn't undermine the usefulness of PSR-7. Frameworks and other libraries can continue calling for PSR-7 compatibility, but consuming applications can still get the benefit of helper methods outside the scope of the interface spec. Am I missing something here? |
Using interfaces is entirely design philosophy. The key point is: Guzzle decided to provide a PSR-7 implementation. If the team would add If you decide that you want to have convenience methods to quickly access the json decoded content (or anything else), you can easily write a wrapper object that accepts a PSR-7 compatible object. And the added benefit of this solution would be that you are not depending on Guzzle - you are depending on ANY PSR-7 implementation. You could even start a new library with just a fancy wrapper object allowing direct access to anything - and this would be beneficial for every user of a PSR-7 compatible library, not only one specific implementation. |
@SvenRtbg Great explanation. Thanks. Although it was very usable. |
i cant't understand why? |
@artickc, call |
Case 1:
|
@artickc I'm not totally sure it's the right place for asking your specific question. You will have more visibility and more quality answers if you ask it on Stackoverflow. |
Reviving an issue that has been closed two years ago will only annoy those that still receive notifications because they answered long ago.
Please open a new issue if you think you have found a bug in Guzzle. Go to Stackoverflow if you need support using Guzzle in your application.
|
Call to undefined method GuzzleHttp\Psr7\Response::json() |
IMHO this is actually simply an omission in the Psr-7 Standard that needs to be fixed. They completely forgot to provide an interface for client-side responses. Crazy but true. If you read the standard, you see "Our recommendation is that implementations use read-only streams for server-side requests and client-side responses" (my emphasis). So the concept of a client-side response is not uncommon to them. Yet, they only have interfaces for:
What is obviously lacking is ClientResponseInterface -- Representation of an incoming, client-side response. That interface would obivously have the getParsedBody() method the same way as ServerRequestInterface has. Please file a bug against the Psr-7 standard. |
* fix path to plugin * fix undefined variable error in commented out code * Vendor with capital V to match existing * update guzzle version to 6.x php composer.phar require guzzlehttp/guzzle:~6.0 * update php github api to current version php composer.phar require knplabs/github-api php-http/guzzle6-adapter ^1.1 * update composer.lock with new dependencies php composer.phar update --with-dependencies * install new vendor modules php composer.phar install * request is PUT/POST https://stackoverflow.com/questions/14713258/cakephp-this-request-ispost-return-false-for-just-one-form-so-strange * switch to guzzle 6 syntax https://stackoverflow.com/questions/27825667/php-guzzlehttp-how-to-make-a-post-request-with-params * use uri per guzzle 6 syntax https://stackoverflow.com/questions/29722822/guzzle-returns-curl-error-3-url-malformed/53831345#53831345 * json() is deprecated in guzzle 6 guzzle/guzzle#1106 * install filesystem adapter for caching php composer.phar require cache/filesystem-adapter * update to current github api using file cache https://github.com/KnpLabs/php-github-api using https://github.com/php-cache/filesystem-adapter as cache * v3 api only returns orgs that user can operate on https://developer.github.com/v3/orgs/#list-your-organizations * remove CoGroupMember as it is no longer given need to use the method that @skoranda uses at https://github.com/Internet2/comanage-registry/blob/db3712032ad743039c5d9a322b031da758ba6373/app/AvailablePlugin/MailmanProvisioner/Model/CoMailmanProvisionerTarget.php#L738 * fixed adding member to team to use v3 api fixes https://todos.internet2.edu/browse/CO-942 * report the id of user missing a github id in error * we cannot remove pending invitations this is due to KnpLabs/php-github-api#713 see also https://todos.internet2.edu/browse/CO-1818 * fix CoGroup to GitHub team provisioning * just skip CoPerson if no GitHub identifier a non-trivial number of CoPersons in a CO might not have a GitHub ID, so just skip them when doing the provisioning otherwise users will get confused by the error * set the github redirect uri this allows the user to set a single base callback url on GitHub for multiple provisioners see https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps/#redirect-urls however see https://todos.internet2.edu/browse/CO-1819 * Revert "just skip CoPerson if no GitHub identifier" This reverts commit da42e2b. * only provision if the coperson is active * strip whitespace from github username * update for syracuse contributions
No more json() method for responses?
Guzzle 5:
Guzzle 6:
Will json() method be back ? (I miss it)
The text was updated successfully, but these errors were encountered: