2
votes

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
Verify you are using the latest version of GuzzleBundle. Are you using any guzzle bundle plugins in AppKernel? The problem might be there. - Cerad
Hey, im using "version": "v7.2.1", thats the latest version available. I dont use any plugins for guzzle. - WhiteRabbit
I suppose you can try doing what the message suggests and add an alias to your services.yml file. The trigger_api service id is being generated by the bundle so you can't mess it with. You could also manually define your service so autowire won't complain. - Cerad
Not sure how to implement your first suggestion. I cant add an alias sinice the services.yml file is in the bundle (vendor dir). If i would add that in my services.yml, it says that its an unknown service since its not loaded then, or am i wrong here ? - WhiteRabbit

1 Answers

3
votes

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.