简体   繁体   English

在Symfony3中创建实体管理器?

[英]Create Entity Manager in Symfony3?

I have an existing entity in a Symfony3 project that I am trying to add an entity manager to. 我正在尝试向其中添加实体管理器的Symfony3项目中已有一个实体。 My doctrine.yml file looks like this 我的doctrine.yml文件看起来像这样

doctrine:
 dbal:
  default_connection: default
    connections:
     default: 
      driver:   pdo_mysql
      host:     localhost
      port:     3306
      dbname:   fullstackdb
      user:     root
      password: root
      charset:  UTF8

   lego:
     driver:   pdo_mysql
     host:     localhost
     port:     3306
     dbname:   fullstackdb
     user:     root
     password: root
     charset:  UTF8


  orm:
   default_entity_manager: default
    entity_managers:
     auto_mapping: true
     default:
      connection: default
       mappings:

    lego:
      connection: lego
       mappings:
        AppBundle: ~

However anytime I try to access this entity manager through php bin/console doctrine:database:create --connection=lego , it says the manager does not exist! 但是,无论何时我尝试通过php bin / console doctrine:database:create --connection = lego访问此实体管理器,都说该管理器不存在! I'm not sure if I'm missing a step - the only thing I've done to create the manager is to make the yml file. 我不确定是否缺少步骤-创建管理器的唯一步骤是制作yml文件。

It doesn't show up when I run bin/console debug:container. 当我运行bin / console debug:container时,它没有显示。 Grateful for any help! 感谢您的帮助!

1) You are using the same schema name (database name) on the same host in two different entity managers without schema_filters. 1)您在两个没有schema_filters的不同实体管理器中的同一主机上使用相同的架构名称(数据库名称)。 This means that when you do an update to one of the entity managers it will attempt to delete the data of the other entity manager. 这意味着,当您对其中一个实体管理器进行更新时,它将尝试删除另一个实体管理器的数据。

2) You are asking about a entity manager but in the command you are passing a connection. 2)您询问的是实体管理器,但是在命令中您正在传递连接。

3) Run php bin/console debug:container | 3)运行php bin /控制台debug:container | grep doctrine 格雷普主义

This will give you all the doctrine services. 这将为您提供所有教义服务。 Update your question accordingly. 相应地更新您的问题。

4) Provide the exact command and exact error you get so we can track it down to the origin 4)提供您得到的确切命令和确切错误,以便我们可以将其追溯到原点

5) For a more information run the command in verbose mode adding -v at the end 5)有关更多信息,请在详细模式下运行命令,并在末尾添加-v

6) Are you importing your doctrine.yml in your config.yml ? 6)您要在config.yml中导入doctrine.yml吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM