Документацияclass TaskController
{
/**
* @var ProducerInterface
*/
private $producer;
public function __construct(ProducerInterface $producer)
{
$this->producer = $producer;
}
public function indexAction($name)
{
$this->producer->publish('test');
return new Response();
}
}
# services.yaml
services:
App\Controller\TaskController:
arguments:
- '@old_sound_rabbit_mq.task_producer'
либо (если producer только одни)
# services.yaml
services:
OldSound\RabbitMqBundle\RabbitMq\ProducerInterface: '@old_sound_rabbit_mq.task_producer'
и понадеяться на autowire
Еще может пригодится:
Local service binding