首页 文章

未加载fos_oauth_server.client_manager.default

提问于
浏览
0

我从上周开始尝试让FOS Auth Server Bundle与Symfony4一起工作 . 如果我想使用我创建的create client命令,则会显示此错误消息 .

编译容器时,“fos_oauth_server.client_manager.default”服务或别名已被删除或内联 . 您应该将其公开,或者直接停止使用容器并改为依赖注入 .

有没有人有同样的问题?

1 回答

  • 4

    我也有同样的问题 . 试图像这样注入服务:

    <?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.
    

    所以我在services.yaml中注册了我的命令:

    App\Command\CreateClientCommand:
             arguments:
                $client_manager: '@fos_oauth_server.client_manager.default'
    

    现在它工作:)

相关问题