i have the same problem. tried to inject the service like that :
<?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;
}
but i got the error :
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.
so i registered my command in services.yaml :
App\Command\CreateClientCommand:
arguments:
$client_manager: '@fos_oauth_server.client_manager.default'
Now it works :)