image icon indicating copy to clipboard operation
image copied to clipboard

guzzlehttp/psr7 v2.0 API change breaks part of the library

Open Cynically opened this issue 2 years ago • 10 comments

Hello,

With the new PSR7 library released a few days ago, some API has changed and it broke the StreamCommand that I was using. Is there any plan to upgrade the API in order to support the latest version of PSR7?

For your reference https://github.com/guzzle/psr7/blob/c0dcda9f54d145bd4d062a6d15f54931a67732f9/README.md#upgrading-from-function-api

Thanks

Cynically avatar Jul 05 '21 19:07 Cynically

Using version ^2.5 for intervention/image
./composer.json has been updated
Running composer update intervention/image
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - intervention/image[2.5.0, ..., 2.5.1] require guzzlehttp/psr7 ~1.1 -> found guzzlehttp/psr7[1.1.0, ..., 1.x-dev] but the package is fixed to 2.0.0 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
    - Root composer.json requires intervention/image ^2.5 -> satisfiable by intervention/image[2.5.0, 2.5.1].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

I'm facing issues with guzzlehttp/psr7 on a new Laravel project. Related?

bilogic avatar Jul 06 '21 07:07 bilogic

I think this will fix it #1094

klaasnicolaas avatar Jul 06 '21 13:07 klaasnicolaas

For those who face this issue as well when running composer require intervention/image on a Laravel 8 install.

Run: composer require intervention/image:"master"

This will get the master branch with fix indicated above in #1094

webinn avatar Jul 08 '21 12:07 webinn

I think this will fix it #1094

why not draft a new released

Scyllaly avatar Jul 10 '21 16:07 Scyllaly

There are 2 issues here. Updating the dependency to ^2.0 will solve @bilogic's issue

In my case, I get an error saying the stream_for() function doesn't exist. For example, if you inspect StreamCommand.php

You'll see this:

$this->setOutput(\GuzzleHttp\Psr7\stream_for(
    $image->encode($format, $quality)->getEncoded()
));

That's because it has been replaced with Utils::streamFor in v2.0. Switching to this works but I am sure it'll break the package for people not using the latest version.

$this->setOutput(\GuzzleHttp\Psr7\Utils::streamFor(
    $image->encode($format, $quality)->getEncoded()
));

Cynically avatar Jul 10 '21 19:07 Cynically

run composer require intervention/image -w

mehrang13 avatar Jul 10 '21 20:07 mehrang13

@Cynically my apologies if I hijacked your issue. To others, my issue has since been resolved with the use of composer require intervention/image -W. There might be other solutions, but this was what worked for me. Thank you.

bilogic avatar Jul 11 '21 03:07 bilogic

This issue is preventing users from uploading avatars in the Flarum software when they make a new installation or update all their dependencies since it automatically makes the PSR7 package jump to ^2.0 and cause the stream_for error https://github.com/flarum/core/issues/2966

We are currently suggesting users require version ^1.1 of PSR7 package manually as a workaround, but a fix here would be appreciated.

clarkwinkelmann avatar Jul 14 '21 21:07 clarkwinkelmann

Same issue here, but I can't use version ^1.1 because ^2.0 is required by other dependencies

"message": "Call to undefined function GuzzleHttp\\Psr7\\stream_for()",
"exception": "Error",
"file": "\\vendor\\intervention\\image\\src\\Intervention\\Image\\Commands\\StreamCommand.php",
"line": 19,

devilstars avatar Jul 15 '21 13:07 devilstars

Facing this issue in my application as well. Image uploads are broken now. Laravel throws the following error:

Call to undefined function GuzzleHttp\Psr7\stream_for()

TheBigK avatar Jul 16 '21 04:07 TheBigK

Please use Version 3 of Intervention Image.

olivervogel avatar Dec 08 '23 18:12 olivervogel