简体   繁体   English

doctrine2实体没有loadMetadata()?

[英]doctrine2 entities don't have loadMetadata()?

I created some doctrine2 entities to go with my database and can create/access the data from the command line. 我创建了一些doctrine2实体与数据库一起使用,并且可以从命令行创建/访问数据。 When I move to a Silex app, I start to run into trouble. 当我转到Silex应用程序时,我开始遇到麻烦。 When I try to get the entityManager to fetch a record it crashes with the following error message: 当我尝试让EntityManager获取记录时,它崩溃并显示以下错误消息:

"Fatal error: Call to undefined method Entities\\User::loadMetadata() in .../vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php on line 79" “致命错误:在第79行的... / vendor / doctrine / common / lib / Doctrine / Common / Persistence / Mapping / Driver / StaticPHPDriver.php中调用未定义的方法Entities \\ User :: loadMetadata()

My composer requires are: 我的作曲家要求:

 "require": {
      "silex/silex": "v1.1.0",
      "symfony/http-foundation": "v2.3.3",
      "doctrine/orm": "2.3.4",
      "dflydev/doctrine-orm-service-provider": "v1.0.1"
 },

Is there some step I messed when creating these entities from my database? 从数据库创建这些实体时,我是否有些步骤混乱? Thanks 谢谢

It seems this problem has to do with the way I setup the DoctrineOrmServiceProvider. 看来此问题与我设置DoctrineOrmServiceProvider的方式有关。 Initially, I set the type to php. 最初,我将类型设置为php。 The correct type for me to use was annotation. 我要使用的正确类型是注释。

$app->register(new DoctrineOrmServiceProvider, array(
    "orm.em.options" => array(
        "mappings" => array(
            array(
                "type" => "annotation",
                "namespace" => "Entities",
                "path" => __DIR__."/../lib/",
            ),
        ),
    ),
));

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

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