问题
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