如何在 Doctrine2 中安装 gedmo 扩展?
我试图在 Doctrine2 中安装 "gedmo" 行为扩展(版本 2.1.0-DEV) (版本 2.1.3)。
没有扩展,一切正常。但是,当我添加注释驱动程序来读取 @gedmo-annotations 错误时,例如“未捕获的异常 'Doctrine\ORM\Mapping\MappingException' 并带有消息 'Class User2 不是有效的实体或映射的超类
” ”被抛出。 这是 de User2-entity:
<?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);
几个问题:
- 我应该为 ORM 注释添加驱动程序吗?
- User2 类有问题吗?
- 如何获得更具体的用户错误,使我能够找到问题的确切原因?
简而言之:如何使 @orm 和 @gedmo 注释起作用?
i'm trying to install the "gedmo" behaviourial extensions (version 2.1.0-DEV) in Doctrine2 (version 2.1.3).
Without the extensions everything works fine. However, when I add the annotationdriver to read the @gedmo-annotations errors such as "Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class User2 is not a valid entity or mapped super class
" are thrown.
This is de User2-entity:
<?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;
}
Because these errors occur even in the Entities where @gemdo is not used i suspect it has something to do with the way the annotationdrivers are configured. In my bootstrap-file the annotation driver is added (i'm only going to use the tree-extension):
$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);
A few questions:
- Should I add a driver for the ORM-annotation?
- Is there something wrong with the User2-class?
- How can I get a more specific user-error enabling me to find the exact cause of the problem?
In short: how can I make the @orm and @gedmo annotations work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最近添加了一个示例,以展示如何配置裸实体管理器无需使用任何框架的扩展。
您可以按照底部的自述文件了解如何初始设置
there was recently an example added in order to show how to configure bare entity manager with extensions whithout any framework used.
You can follow the readme at the bottom on how to setup it initially