【问题标题】:Symfony - Placing Entities outside of any BundleSymfony - 将实体放在任何 Bundle 之外
【发布时间】:2015-12-08 17:02:06
【问题描述】:

我试图将实体放在我的 Symfony 项目之外,因为我希望 Doctrine 实体与其他东西共享。我阅读了文档并在 config.yml 中提出了这个

orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    naming_strategy: doctrine.orm.naming_strategy.underscore
    auto_mapping:   false
    mappings:
        backend:
            type:   annotation
            dir:    %kernel.root_dir%/../../common/Backend/Entity
            prefix: Backend\Entity
            alias: Backend
            is_bundle:  false

但是,当我启动应用程序/尝试加载依赖数据的页面时,我收到此错误:

[Doctrine\Common\Persistence\Mapping\MappingException]  
  Class 'Backend\Entity\PortalUser' does not exist 

我猜我需要告诉 Symfony 查看一个目录,但我认为这是由“dir”配置完成的。所以我在这里遗漏了一些东西。

composer.json 中的自动加载配置:

"autoload": {
        "psr-4": {
           "": ["src/","../common/"]
        },
        "files": [
            "app/AppKernel.php"
        ]
    },

【问题讨论】:

    标签: php doctrine-orm symfony


    【解决方案1】:

    composer.json 上的自动加载配置是什么样的?这就是失败的地方。

    【讨论】:

    • 我必须在更新 composer.json (facepalm) 后运行 composer update .. 仅此而已。感谢您的帮助
    猜你喜欢
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 1970-01-01
    • 2019-05-17
    相关资源
    最近更新 更多