Symfony 3.3 - Autowiring Deprecation Guzzle

风流意气都作罢 提交于 2019-12-24 00:44:58

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/47574194/symfony-3-3-autowiring-deprecation-guzzle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!