【问题标题】:How to install the gedmo-extensions in Doctrine2?如何在 Doctrine2 中安装 gedmo 扩展?
【发布时间】:2011-12-19 14:25:00
【问题描述】:

我正在尝试在 Doctrine2(版本 2.1.3)中安装 "gedmo" behaviourial extensions (version 2.1.0-DEV)

没有扩展一切正常。但是,当我添加注释驱动程序以读取 @gedmo-annotations 时,会抛出诸如“Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class User2 is not a valid entity or mapped super class”之类的错误。 这是 de User2 实体:

<?php

use \Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity  */
class User2 {

    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    private $id;

    /** @ORM\Column(length=255) */
    private $username;
}

因为即使在不使用@gemdo 的实体中也会发生这些错误,我怀疑它与注释驱动程序的配置方式有关。在我的引导文件中添加了注释驱动程序(我只会使用树扩展):

$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);

$chain = new \Doctrine\ORM\Mapping\Driver\DriverChain;
$chain->addDriver($annotationDriver, 'Gedmo\Tree\Entity');

$config->setMetadataDriverImpl($chain);

几个问题:

  1. 我应该为 ORM 注释添加驱动程序吗?
  2. User2 类有问题吗?
  3. 如何获得更具体的用户错误,以便找到问题的确切原因?

简而言之:如何使@orm 和@gedmo 注释起作用?

【问题讨论】:

    标签: php orm tree doctrine-orm behavior


    【解决方案1】:

    最近添加了一个example,以展示如何在不使用任何框架的情况下使用扩展配置裸实体管理器。 您可以按照底部的readme 了解如何进行初始设置

    【讨论】:

      猜你喜欢
      • 2016-09-28
      • 2018-01-10
      • 2015-07-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-31
      相关资源
      最近更新 更多