"Missing Service" 在 Symfony 中声明新主题时

"Missing Service" When declare new Topic in Symfony

我正在我的应用程序上实现套接字,所以我执行了以下步骤:

  1. 创建主题处理程序服务,如 this 但在其 __construct 方法上使用实体管理器。

    public function __construct(EntityManager $em, ClientManipulatorInterface $client) {
        $this->em = $em;
        $this->client = $client;
    }
    
  2. 使用 symfony 注册您的服务。

    2.1。文件 services.yml 如下所示:

    foo.topic: 
        class: AppBundle\Topic\FooTopic
        arguments:["@doctrine.orm.personem_entity_manager", "@gos_web_socket.websocket.client_manipulator"]
        tags:
          -{ name: gos_web_socket.topic}
    

    这里是我在传递的第一个参数中收到错误缺少服务的时候。 我找不到我的实体管理器,但我已经在我的 conf 文件中声明了它。

    personem:
        dql:
          string_functions:
            convert: AppBundle\Dql\ConvertFunction
        connection: connection
        mappings:
          GptIReunionBundle: ~
          AppBundle: ~
    

有什么想法吗?

问题是,我在 local 环境中使用 service.yml 并且我没有在我的 config_prod.yml 文件中声明实体管理器。

所以我解决了在所有环境中创建实体管理器的问题。