You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #35245 [HttpClient] fix exception in case of PSR17 discovery failure (nicolas-grekas)
This PR was merged into the 4.4 branch.
Discussion
----------
[HttpClient] fix exception in case of PSR17 discovery failure
| Q | A
| ------------- | ---
| Branch? | 4.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Tickets | -
| License | MIT
| Doc PR | -
On symfony.com, we need to use HTTPlug for 3rd party libs. When `nyholm/psr7` is not installed, we currently see an exception saying `No HTTPlug clients found.` from `HttpClientDiscovery`.
This fixes the message by correctly suggesting `nyholm/psr7` instead, since there *is* an HTTPlug client: `HttplugClient` from our HttpClient component.
It's quite unfortunate that `guzzle/psr7` provides no PSR17 factory yet, because that would have solved some part of this deps mess. /cc @Nyholm@sagikazarmark FYI
Note that https://packagist.org/providers/psr/http-factory-implementation lists `guzzle/psr7` but this is a wrong solution: no tagged release of it is PSR17-compatible, which means installing it doesn't solve the issue.
Commits
-------
96e70a4 [HttpClient] fix exception in case of PSR17 discovery failure
Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/HttplugClient.php
+8-3Lines changed: 8 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,7 @@
16
16
useHttp\Client\Exception\RequestException;
17
17
useHttp\Client\HttpAsyncClient;
18
18
useHttp\Client\HttpClientasHttplugInterface;
19
+
useHttp\Discovery\Exception\NotFoundException;
19
20
useHttp\Discovery\Psr17FactoryDiscovery;
20
21
useHttp\Message\RequestFactory;
21
22
useHttp\Message\StreamFactory;
@@ -75,9 +76,13 @@ public function __construct(HttpClientInterface $client = null, ResponseFactoryI
75
76
thrownew \LogicException('You cannot use the "Symfony\Component\HttpClient\HttplugClient" as no PSR-17 factories have been provided. Try running "composer require nyholm/psr7".');
thrownew \LogicException('You cannot use the "Symfony\Component\HttpClient\HttplugClient" as no PSR-17 factories have been found. Try running "composer require nyholm/psr7".', 0, $e);
Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/Psr18Client.php
+8-3Lines changed: 8 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@
11
11
12
12
namespaceSymfony\Component\HttpClient;
13
13
14
+
useHttp\Discovery\Exception\NotFoundException;
14
15
useHttp\Discovery\Psr17FactoryDiscovery;
15
16
useNyholm\Psr7\Factory\Psr17Factory;
16
17
useNyholm\Psr7\Request;
@@ -68,9 +69,13 @@ public function __construct(HttpClientInterface $client = null, ResponseFactoryI
68
69
thrownew \LogicException('You cannot use the "Symfony\Component\HttpClient\Psr18Client" as no PSR-17 factories have been provided. Try running "composer require nyholm/psr7".');
thrownew \LogicException('You cannot use the "Symfony\Component\HttpClient\HttplugClient" as no PSR-17 factories have been found. Try running "composer require nyholm/psr7".', 0, $e);
0 commit comments