<?php
namespace App\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use FOS\OAuthServerBundle\Entity\ClientManager;
class CreateClientCommand extends ContainerAwareCommand
{
protected static $defaultName = 'create:client';
private $client_manager;
public function __construct(ClientManager $client_manager)
{
parent::__construct();
$this->client_manager = $client_manager;
}
但我得到了错误:
Cannot autowire service "App\Command\CreateClientCommand": argument "$client_manager" of method "__construct()" ref
erences class "FOS\OAuthServerBundle\Entity\ClientManager" but no such service exists. It cannot be auto-registered
because it is from a different root namespace.
1 回答
我也有同样的问题 . 试图像这样注入服务:
但我得到了错误:
所以我在services.yaml中注册了我的命令:
现在它工作:)