diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 19386d9721ae9..cea61eddd16c1 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -13,6 +13,7 @@
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\Common\Annotations\Reader;
+use Http\Client\HttpClient;
use Psr\Cache\CacheItemPoolInterface;
use Psr\Container\ContainerInterface as PsrContainerInterface;
use Psr\Http\Client\ClientInterface;
@@ -60,7 +61,6 @@
use Symfony\Component\Form\FormTypeExtensionInterface;
use Symfony\Component\Form\FormTypeGuesserInterface;
use Symfony\Component\Form\FormTypeInterface;
-use Symfony\Component\HttpClient\Psr18Client;
use Symfony\Component\HttpClient\ScopingHttpClient;
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
@@ -1881,6 +1881,10 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
$container->removeAlias(ClientInterface::class);
}
+ if (!interface_exists(HttpClient::class)) {
+ $container->removeDefinition(HttpClient::class);
+ }
+
foreach ($config['scoped_clients'] as $name => $scopeConfig) {
if ('http_client' === $name) {
throw new InvalidArgumentException(sprintf('Invalid scope name: "%s" is reserved.', $name));
@@ -1901,9 +1905,8 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
$container->registerAliasForArgument($name, HttpClientInterface::class);
if ($hasPsr18) {
- $container->register('psr18.'.$name, Psr18Client::class)
- ->setAutowired(true)
- ->setArguments([new Reference($name)]);
+ $container->setDefinition('psr18.'.$name, new ChildDefinition('psr18.http_client'))
+ ->replaceArgument(0, new Reference($name));
$container->registerAliasForArgument('psr18.'.$name, ClientInterface::class, $name);
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.xml
index aa29944c472d3..a3f0884365b0a 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.xml
+++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/http_client.xml
@@ -22,5 +22,11 @@
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: