How can i inject dependencies to Symfony Console commands?

后端 未结 7 1015
醉话见心
醉话见心 2020-12-09 08:00

I\'m writing an open source application uses some Symfony components, and using Symfony Console component for interacting with shell.

But, i need to inject dependen

7条回答
  •  -上瘾入骨i
    2020-12-09 08:12

    In Symfony 3.4, if autowire is configured correctly, services can be injected into the constructor of the command.

    public function __construct(
        \AppBundle\Handler\Service\AwsS3Handler $s3Handler
    ) {
        parent::__construct();
    
        $this->s3Handler = $s3Handler;
    }
    

提交回复
热议问题