doutou19761022 2014-05-01 00:34
浏览 44
已采纳

在symfony2中设置orm配置与Sylius类似

I'm having a tough time setting up doctrine ORM configuration using Symfony2. I'm setting up the ORM files using yml.

I've looked at a couple of open source Symfony2 projects(mostly Sylius) and the norm seems to be placing Entities outsides of the bundles in a folder called Components but placing the ORM definitions in the bundles. Can anyone suggest any useful resources to help me set this up? The default seems to require my entities to be within bundles which I don't want to do because some of my entities have scope across multiple bundles.

I've noticed in the documentation you can configure entity managers individually but I can't see how the configuration options below can achieve what I'm after, especially because the entities may not all share the same prefix:

mappings:
    AcmeOrderBundle:
        type:              ~
        dir:               ~
        alias:             ~
        prefix:            ~
        is_bundle:         ~

Any help with this would be greatly appreciated and I can provide more information if necessary.

  • 写回答

1条回答 默认 最新

  • douchujian8124 2014-05-01 04:33
    关注

    Here is an example using a couple of the options:

        entity_managers:
    
            games:
               connection: games
               mappings:
                    CeradGameBundle: 
                        type:   yml
                        dir:    Resources/config/doctrine2
                        prefix: Cerad\Bundle\GameBundle\Doctrine\Entity
    

    The dir points to where the orm.yml files live. As shown it is relative to the bundle. But you can replace it with an absolute path if you want.

    The prefix is basically the namespace of your entities.

    As far as multiple prefixes go, you can have multiple mappings for a given manager. Make one mapping per prefix.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥30 在CodBlock上用c++语言运行
  • ¥15 求C6748 IIC EEPROM程序固化烧写算法
  • ¥50 关于#php#的问题,请各位专家解答!
  • ¥15 python 3.8.0版本,安装官方库ibm_db遇到问题,提示找不到ibm_db模块。如何解决?
  • ¥15 TMUXHS4412如何防止静电,
  • ¥30 Metashape软件中如何将建模后的图像中的植被与庄稼点云删除
  • ¥20 机械振动学课后习题求解答
  • ¥15 IEC61850 客户端和服务端的通讯机制
  • ¥15 MAX98357a(关键词-播放音频)
  • ¥15 Linux误删文件,请求帮助
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部