symfonyauthenticationfosrestbundlefosoauthserverbundle

fos_oauth_server.client_manager.default is not loaded


I'm trying since last week to get the FOS Auth Server Bundle working with Symfony4. If I want to use the create client Command which I created this error message appears.

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 dependency injection instead.

Is there anyone with the same problem?


Solution

  • 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 :)