Symfony 3.3-自动装配弃用枪口 [英] Symfony 3.3 - Autowiring Deprecation Guzzle
问题描述
由于我计划升级我的Symfony版本,因此我想删除所有弃用项.我不知道如何清除最后两个错误.
一个是
Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. You should rename (or alias) the "eight_points_guzzle.client.trigger_api" service to "GuzzleHttp\ClientInterface" instead.
但是在我的秘密中,我已经使用客户端界面进行注入
public function __construct(
LoggerInterface $logger,
EntityManagerInterface $em,
ClientInterface $client
) {
$this->em = $em;
$this->logger = $logger;
$this->rest = $client;
}
创建的是与我的客户端(在config.yml中配置)的guzzle客户端 three_points_guzzle.client .trigger_api
我正在使用此捆绑包: https://github.com/8p/EightPointsGuzzleBundle >
有什么办法解决这个问题吗?
预先感谢您, 问候兔子
简短答案:在您的应用程序的services.yml中添加以下行:
services:
GuzzleHttp\ClientInterface: "@eight_points_guzzle.client.trigger_api"
请注意,该格式为 yaml 格式,如果您使用其他格式,请进行相应调整.
长答案:Symfony中的自动装配已更改自动装配文档 您的服务具有 ClientInterface $ client 作为依赖关系,并且此依赖关系由symfony自动连接. Symfony过去曾按类型自动为其连接,但已弃用.现在,必须定义一个以接口为名称和要注入资源别名的服务.
since i plan to upgrade my Symfony version i want to remove all Deprecations. I cant figure out how to remove my last two errors.
One is
Autowiring services based on the types they implement is deprecated since Symfony 3.3 and won't be supported in version 4.0. You should rename (or alias) the "eight_points_guzzle.client.trigger_api" service to "GuzzleHttp\ClientInterface" instead.
But in my serivce, i already use the client interface to inject
public function __construct(
LoggerInterface $logger,
EntityManagerInterface $em,
ClientInterface $client
) {
$this->em = $em;
$this->logger = $logger;
$this->rest = $client;
}
what that creates is the guzzle client with my client (configured in config.yml) eight_points_guzzle.client .trigger_api
I am using this bundle : https://github.com/8p/EightPointsGuzzleBundle
Any ideas how to fix that ?
Thank you in advance, Greetings Rabbit
Short answer: Add the following line in your services.yml of your application:
services:
GuzzleHttp\ClientInterface: "@eight_points_guzzle.client.trigger_api"
Note this is in yaml format, if you use another, adjust accordingly.
Long answer: Autowiring has changed in Symfony Autowiring documentation Your service has ClientInterface $client as dependency, and this dependency is autowired by symfony. Symfony used to autowire this by type, but this is deprecated. Now a service with the interface as its name and alias to the resource to inject has to be defined.
这篇关于Symfony 3.3-自动装配弃用枪口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!