Skip to content
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

Call to undefined function GuzzleHttp\Psr7\stream_for() #470

Closed
RobinBoersma opened this issue Jul 27, 2021 · 21 comments
Closed

Call to undefined function GuzzleHttp\Psr7\stream_for() #470

RobinBoersma opened this issue Jul 27, 2021 · 21 comments

Comments

@RobinBoersma
Copy link

RobinBoersma commented Jul 27, 2021

Error: Call to undefined function GuzzleHttp\Psr7\stream_for() #7 zendesk/zendesk_api_client_php/src/Zendesk/API/Http.php(69): Zendesk\API\Http::send #6 zendesk/zendesk_api_client_php/src/Zendesk/API/HttpClient.php(494): Zendesk\API\HttpClient::post #5 zendesk/zendesk_api_client_php/src/Zendesk/API/Resources/Core/Tickets.php(164): Zendesk\API\Resources\Core\Tickets::create

@RobinBoersma
Copy link
Author

#471
#472

@spencerrlongg
Copy link
Contributor

this is also fixed via #469
we'd love to get one of these solutions merged ASAP if at all possible.

@Bitflinx
Copy link

Bitflinx commented Aug 9, 2021

Quickfix: Goto: \vendor\zendesk\zendesk_api_client_php\src\Zendesk\API\HTTP.php Line 70 and replace

//Corrected cause of error
$request = $request->withBody(\GuzzleHttp\Psr7\Utils::streamFor(json_encode($options['postFields'])));

//Original code
//$request = $request->withBody(\GuzzleHttp\Psr7\stream_for(json_encode($options['postFields'])));

This was referenced Aug 10, 2021
@kevinirlen
Copy link

kevinirlen commented Sep 2, 2021

I don't know if Zendesk is willing to merge this.. A quick & MacGyver solution, instead of modifying the core files. Create a directory in your project

GuzzleHttp/psr

And paste in the code below

<?php
# functions.php

namespace GuzzleHttp\Psr7;

/**
 *
 * @param string $resource
 * @param array  $options
 *
 * @return PumpStream|Stream|\Psr\Http\Message\StreamInterface
 */
function stream_for($resource = '', array $options = [])
{
    return Utils::streamFor($resource, $options);
}

@XVII
Copy link

XVII commented Sep 9, 2021

Merge please @zendesk 😇

@BafS
Copy link

BafS commented Sep 27, 2021

@thekindofme, @gkatechis, @gmponos, @nogates sorry to ping you guys but would it be possible to merge one of the fixes (like #469)? The requirement is not correct and it's easy to mess-up.

The current workaround is to add a function like @kevinirlen proposes or to require explicitly and old version of guzzlehttp/psr7 (composer req "guzzlehttp/psr7:^1").

Thanks in advance

@PierreGranger
Copy link

#471 and #472 would be a perfect response.
This problem is major because any update cause a fault as soon as guzzle is updated to a recent version.

Thanks for your help !

@simonmaass
Copy link

simonmaass commented Oct 26, 2021

if you want backward compatibility with guzzle 6.x... then i think the cleanest solution for now would be to require "guzzlehttp/psr7": "^1.8.3", in the composer.json for this project... at least a clean composer install would not break anymore...

@thekindofme ping

@Braunson
Copy link

Braunson commented Oct 26, 2021

Huge problem, this just occurred on production for me. A workaround is to do what @simonmaass mentioned.

@Huggyduggy
Copy link

As it might be helpful to some - I didn't want to mess with my directory structure, thus I've saved @kevinirlen into a file within my usual workspace (called functions.php) and used composer to autoload this file:

composer.json:

"autoload": { "classmap": [ "database", "app/Libraries" ], "psr-4": { "myNamespace\\": "app/" }, "files": [ **"app/Libraries/Internal/Fixes/Psr7/functions.php"** ] },

@paulrwest
Copy link

Any news on a timeframe for a merge?

Thanks for posting the workarounds guys

@Pierstoval
Copy link

Do you folks need a cross-compatible version of the fix that would comply with multiple versions of Guzzle, maybe?
At least 3 unmerged PRs:

A cross-compatible version should be easy, a simple if (function_exists(...)) should do the trick.

I would've created a PR, but since there's lots of them already, I didn't want to pollute the current state of the project.

However, I'm one of the several people whose production broke because of this, and I had to use a dirty quickfix for that which I don't like at all, so as others, I wish this could be fixed and released soon 😉

@chrisminett
Copy link
Contributor

For those following this, it looks like it will have been resolved as #469 has been merged, and these changes are included in release v2.2.12

@BafS
Copy link

BafS commented Jan 6, 2022

It seems that packagist is not updated automatically, the last ^v2 is still v2.2.11 (https://packagist.org/packages/zendesk/zendesk_api_client_php). You can use "dev-master" or the specific commit as a workaround.

@InjustFr
Copy link

dev-master actually doesn't work directly as it isn't updated on packagist as well. You'll have to add this repository in your composer.json before being able to pull for dev-master or v2.2.11

@BafS
Copy link

BafS commented Jan 10, 2022

You are right

@vanessametageek
Copy link

It looks like it is on packagist now.

@ERuban
Copy link

ERuban commented Mar 4, 2022

I have guzzlehttp/psr7:2.1 dependency in my project (from auth0/auth0-php:^8). So in my case the last version I'm able to install is 2.2.11 that has this issue 😒

@gjuric
Copy link

gjuric commented Mar 11, 2022

Can you release a new version that allows guzzle psr7 v2 to be installed?

@ecoologic
Copy link
Contributor

Hi,

thank you for your request,
are you still interested in a solution for this issue?

@ecoologic
Copy link
Contributor

Closing due to inactivity. Re-open if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet