I am trying to create custom command in Symfony 4 project
class AppOauthClientCreateCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('app:oauth-client:create')
->setDescription('Create a new OAuth client');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$clientManager = $this->getContainer()->get('fos_oauth_server.client_manager.default');
$client = $clientManager->createClient();
$client->setAllowedGrantTypes(array(OAuth2::GRANT_TYPE_USER_CREDENTIALS));
$clientManager->updateClient($client);
$output->writeln(sprintf('client_id=%s_%s', $client->getId(), $client->getRandomId()));
$output->writeln(sprintf('client_secret=%s', $client->getSecret()));
}
}
I am getting following error when I try to run this command
The "fos_oauth_server.client_manager.default" service or alias has been removed or inlined when the container was compiled. You should either
make it public, or stop using the container directly and use dependency injection instead.
How do I make vendor service public or am I missing something in command configurations?