From cad50787e29571342a20327382e60398339a98e7 Mon Sep 17 00:00:00 2001 From: Kevin Kaniaburka Date: Thu, 27 Apr 2023 12:53:42 +0200 Subject: [PATCH] Drop Guzzle adapters to support both Guzzle 6 and 7 --- UPGRADE-1.13.md | 13 +++++++++++-- composer.json | 4 ++-- .../Tests/Controller/NotificationControllerTest.php | 3 +-- src/Sylius/Bundle/AdminBundle/composer.json | 1 - src/Sylius/Bundle/ApiBundle/composer.json | 3 +-- src/Sylius/Bundle/CoreBundle/composer.json | 3 --- src/Sylius/Bundle/PayumBundle/composer.json | 4 ++-- src/Sylius/Bundle/UserBundle/composer.json | 1 - src/Sylius/Component/Core/composer.json | 5 ++++- symfony.lock | 9 --------- 10 files changed, 21 insertions(+), 25 deletions(-) diff --git a/UPGRADE-1.13.md b/UPGRADE-1.13.md index cebe051bd4..c969df6a94 100644 --- a/UPGRADE-1.13.md +++ b/UPGRADE-1.13.md @@ -67,8 +67,17 @@ To add more data per variant create a service implementing the `Sylius\Component\Core\Provider\ProductVariantMap\ProductVariantMapProviderInterface` and tag it with `sylius.product_variant_data_map_provider`. -1. Using Guzzle 6 has been deprecated in favor of Symfony HTTP Client. - Therefore, the constructor of `Sylius\Bundle\AdminBundle\Controller\NotificationController` has been changed: +1. Using Guzzle 6 has been deprecated in favor of Symfony HTTP Client. If you want to still use Guzzle 6 or Guzzle 7, + you need to install `composer require php-http/guzzle6-adapter` or `composer require php-http/guzzle7-adapter` + depending on your Guzzle version. + Subsequently, you need to register the adapter as a `Psr\Http\Client\ClientInterface` service as the following: + ```yaml + services: + Psr\Http\Client\ClientInterface: + class: Http\Adapter\Guzzle7\Client # for Guzzle 6 use Http\Adapter\Guzzle6\Client instead + ``` + +1. The constructor of `Sylius\Bundle\AdminBundle\Controller\NotificationController` has been changed: ```diff public function __construct( diff --git a/composer.json b/composer.json index 785787b5a2..25b4ab330e 100644 --- a/composer.json +++ b/composer.json @@ -48,7 +48,7 @@ "friendsofphp/proxy-manager-lts": "^1.0.7", "friendsofsymfony/rest-bundle": "^3.0", "gedmo/doctrine-extensions": "^3.2", - "guzzlehttp/guzzle": "^6.5", + "guzzlehttp/guzzle": "^6.5 || ^7.0", "guzzlehttp/psr7": "^1.8", "jms/serializer-bundle": "^4.2", "knplabs/gaufrette": "^0.10 || ^0.11", @@ -63,7 +63,7 @@ "pagerfanta/pagerfanta": "^3.0", "payum/payum": "^1.7.2", "payum/payum-bundle": "^2.5", - "php-http/guzzle6-adapter": "^2.0", + "php-http/httplug": "^2.4", "php-http/message-factory": "^1.0", "psr/cache": "^2.0", "psr/http-client": "^1.0", diff --git a/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php b/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php index 35486060f2..8d0d098f32 100644 --- a/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php +++ b/src/Sylius/Bundle/AdminBundle/Tests/Controller/NotificationControllerTest.php @@ -14,7 +14,6 @@ declare(strict_types=1); namespace Sylius\Bundle\AdminBundle\Tests\Controller; use GuzzleHttp\Exception\ConnectException; -use Http\Client\Exception\NetworkException; use Http\Message\MessageFactory; use PHPUnit\Framework\TestCase; use Prophecy\Argument; @@ -62,7 +61,7 @@ final class NotificationControllerTest extends TestCase $requestInterface->withHeader('Content-Type', 'application/json')->willReturn($requestInterface); $requestInterface->withBody($streamInterface)->willReturn($requestInterface); - $this->client->sendRequest(Argument::cetera())->willThrow(NetworkException::class); + $this->client->sendRequest(Argument::cetera())->willThrow(ConnectException::class); $emptyResponse = $this->controller->getVersionAction(new Request()); diff --git a/src/Sylius/Bundle/AdminBundle/composer.json b/src/Sylius/Bundle/AdminBundle/composer.json index 379121f2ce..036d2d0eaf 100644 --- a/src/Sylius/Bundle/AdminBundle/composer.json +++ b/src/Sylius/Bundle/AdminBundle/composer.json @@ -36,7 +36,6 @@ "sylius/core-bundle": "^1.12", "sylius/ui-bundle": "^1.12", "symfony/framework-bundle": "^5.4.21 || ^6.0", - "symfony/http-client": "^5.4.21 || ^6.0", "symfony/webpack-encore-bundle": "^1.15", "twig/intl-extra": "^2.12 || ^3.4", "twig/twig": "^2.12 || ^3.3" diff --git a/src/Sylius/Bundle/ApiBundle/composer.json b/src/Sylius/Bundle/ApiBundle/composer.json index 9fd47384fc..95d6b521f1 100644 --- a/src/Sylius/Bundle/ApiBundle/composer.json +++ b/src/Sylius/Bundle/ApiBundle/composer.json @@ -29,8 +29,7 @@ "enshrined/svg-sanitize": "^0.16", "lexik/jwt-authentication-bundle": "^2.11", "sylius/core-bundle": "^1.12", - "symfony/messenger": "^5.4.21 || ^6.0", - "symfony/http-client": "^5.4.21 || ^6.0" + "symfony/messenger": "^5.4.21 || ^6.0" }, "require-dev": { "ext-sqlite3": "*", diff --git a/src/Sylius/Bundle/CoreBundle/composer.json b/src/Sylius/Bundle/CoreBundle/composer.json index d600b6d8fb..f840c8ab5b 100644 --- a/src/Sylius/Bundle/CoreBundle/composer.json +++ b/src/Sylius/Bundle/CoreBundle/composer.json @@ -36,8 +36,6 @@ "league/flysystem-bundle": "^2.4", "liip/imagine-bundle": "^2.10", "nyholm/psr7": "^1.6", - "psr/http-client": "^1.0", - "psr/http-message": "^1.0", "sonata-project/block-bundle": "^4.2", "sylius-labs/association-hydrator": "^1.1 || ^1.2", "sylius-labs/doctrine-migrations-extra-bundle": "^0.1.4 || ^0.2", @@ -68,7 +66,6 @@ "sylius/ui-bundle": "^1.12", "sylius/user-bundle": "^1.12", "symfony/framework-bundle": "^5.4.21 || ^6.0", - "symfony/http-client": "^5.4.21 || ^6.0", "symfony/intl": "^5.4.21 || ^6.0", "symfony/mailer": "^5.4.21 || ^6.0", "symfony/messenger": "^5.4.21 || ^6.0", diff --git a/src/Sylius/Bundle/PayumBundle/composer.json b/src/Sylius/Bundle/PayumBundle/composer.json index b88825f0bc..ef8f2900f3 100644 --- a/src/Sylius/Bundle/PayumBundle/composer.json +++ b/src/Sylius/Bundle/PayumBundle/composer.json @@ -31,12 +31,12 @@ "php": "^8.0", "payum/payum": "^1.7.2", "payum/payum-bundle": "^2.5", - "php-http/guzzle6-adapter": "^2.0", "sylius/core": "^1.12", "sylius/currency": "^1.12", "sylius/order-bundle": "^1.12", "sylius/payment-bundle": "^1.12", - "sylius/resource-bundle": "^1.9" + "sylius/resource-bundle": "^1.9", + "php-http/httplug": "^2.4" }, "require-dev": { "phpspec/phpspec": "^7.2", diff --git a/src/Sylius/Bundle/UserBundle/composer.json b/src/Sylius/Bundle/UserBundle/composer.json index 71f9f49320..b05a5db5bc 100644 --- a/src/Sylius/Bundle/UserBundle/composer.json +++ b/src/Sylius/Bundle/UserBundle/composer.json @@ -55,7 +55,6 @@ "require-dev": { "hwi/oauth-bundle": "^1.1 || ^2.0@beta", "matthiasnoback/symfony-dependency-injection-test": "^4.2", - "php-http/guzzle6-adapter": "^2.0", "phpspec/phpspec": "^7.2", "phpunit/phpunit": "^9.5", "symfony/dependency-injection": "^5.4.21 || ^6.0", diff --git a/src/Sylius/Component/Core/composer.json b/src/Sylius/Component/Core/composer.json index c20a212195..4da0ddd3a3 100644 --- a/src/Sylius/Component/Core/composer.json +++ b/src/Sylius/Component/Core/composer.json @@ -28,10 +28,12 @@ "require": { "php": "^8.0", "enshrined/svg-sanitize": "^0.16", + "guzzlehttp/guzzle": "^6.5 || ^7.0", "knplabs/gaufrette": "^0.10 || ^0.11", "league/flysystem": "^2.4", "payum/payum": "^1.7.2", - "php-http/guzzle6-adapter": "^2.0", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0", "sylius/addressing": "^1.12", "sylius/attribute": "^1.12", "sylius/channel": "^1.12", @@ -50,6 +52,7 @@ "sylius/taxation": "^1.12", "sylius/taxonomy": "^1.12", "sylius/user": "^1.12", + "symfony/http-client": "^5.4.21 || ^6.0", "symfony/http-foundation": "^5.4.21 || ^6.0", "symfony/mime": "^5.4.21 || ^6.0", "symfony/string": "^5.4.21 || ^6.0", diff --git a/symfony.lock b/symfony.lock index ede6009ae8..3831b13099 100644 --- a/symfony.lock +++ b/symfony.lock @@ -406,21 +406,12 @@ "phar-io/version": { "version": "2.0.1" }, - "php-http/guzzle6-adapter": { - "version": "v1.1.1" - }, - "php-http/httplug": { - "version": "v1.1.0" - }, "php-http/message": { "version": "1.7.0" }, "php-http/message-factory": { "version": "v1.0.2" }, - "php-http/promise": { - "version": "v1.0.0" - }, "phparkitect/phparkitect": { "version": "0.2.9" },