Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 46e47e8

Browse filesBrowse files
simonbergernicolas-grekas
authored andcommitted
[FrameworkBundle] Add scoped httplug clients and deprecate httplugs use like psr18 client
1 parent 307ff44 commit 46e47e8
Copy full SHA for 46e47e8

File tree

Expand file treeCollapse file tree

3 files changed

+20
-3
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+20
-3
lines changed

‎CHANGELOG.md

Copy file name to clipboardExpand all lines: CHANGELOG.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ CHANGELOG
1818
* Add `framework.http_cache.skip_response_headers` option
1919
* Display warmers duration on debug verbosity for `cache:clear` command
2020
* Add `AbstractController::sendEarlyHints()` to send HTTP Early Hints
21+
* Add autowiring aliases for `Http\Client\HttpAsyncClient`
22+
* Deprecate the `Http\Client\HttpClient` service, use `Psr\Http\Client\ClientInterface` instead
2123

2224
6.2
2325
---

‎DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: DependencyInjection/FrameworkExtension.php
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Composer\InstalledVersions;
1515
use Doctrine\Common\Annotations\Reader;
16+
use Http\Client\HttpAsyncClient;
1617
use Http\Client\HttpClient;
1718
use phpDocumentor\Reflection\DocBlockFactoryInterface;
1819
use phpDocumentor\Reflection\Types\ContextFactory;
@@ -2354,8 +2355,10 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
23542355
$container->removeAlias(ClientInterface::class);
23552356
}
23562357

2357-
if (!ContainerBuilder::willBeAvailable('php-http/httplug', HttpClient::class, ['symfony/framework-bundle', 'symfony/http-client'])) {
2358-
$container->removeDefinition(HttpClient::class);
2358+
if (!$hasHttplug = ContainerBuilder::willBeAvailable('php-http/httplug', HttpAsyncClient::class, ['symfony/framework-bundle', 'symfony/http-client'])) {
2359+
$container->removeDefinition('httplug.http_client');
2360+
$container->removeAlias(HttpAsyncClient::class);
2361+
$container->removeAlias(HttpClient::class);
23592362
}
23602363

23612364
if ($this->readConfigEnabled('http_client.retry_failed', $container, $retryOptions)) {
@@ -2425,6 +2428,13 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
24252428

24262429
$container->registerAliasForArgument('psr18.'.$name, ClientInterface::class, $name);
24272430
}
2431+
2432+
if ($hasHttplug) {
2433+
$container->setDefinition('httplug.'.$name, new ChildDefinition('httplug.http_client'))
2434+
->replaceArgument(0, new Reference($name));
2435+
2436+
$container->registerAliasForArgument('httplug.'.$name, HttpAsyncClient::class, $name);
2437+
}
24282438
}
24292439

24302440
if ($responseFactoryId = $config['mock_response_factory'] ?? null) {

‎Resources/config/http_client.php

Copy file name to clipboardExpand all lines: Resources/config/http_client.php
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
1313

14+
use Http\Client\HttpAsyncClient;
1415
use Psr\Http\Client\ClientInterface;
1516
use Psr\Http\Message\ResponseFactoryInterface;
1617
use Psr\Http\Message\StreamFactoryInterface;
@@ -49,13 +50,17 @@
4950

5051
->alias(ClientInterface::class, 'psr18.http_client')
5152

52-
->set(\Http\Client\HttpClient::class, HttplugClient::class)
53+
->set('httplug.http_client', HttplugClient::class)
5354
->args([
5455
service('http_client'),
5556
service(ResponseFactoryInterface::class)->ignoreOnInvalid(),
5657
service(StreamFactoryInterface::class)->ignoreOnInvalid(),
5758
])
5859

60+
->alias(HttpAsyncClient::class, 'httplug.http_client')
61+
->alias(\Http\Client\HttpClient::class, 'httplug.http_client')
62+
->deprecate('symfony/framework-bundle', '6.3', 'The "%alias_id%" service is deprecated, use "'.ClientInterface::class.'" instead.')
63+
5964
->set('http_client.abstract_retry_strategy', GenericRetryStrategy::class)
6065
->abstract()
6166
->args([

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.