我在PHP项目中使用Doctrine 2.6.2。该模式已使用ORM-Tool成功创建,但是在运行时会引发MappingException。
我仍然无法理解异常错误消息“ ...中不存在类'凭据'”,因为我不了解教义内部。
我的composer.json文件:
{
"require": {
"doctrine/orm": "^2.6.2",
"symfony/yaml": "2.*"
},
"autoload": {
"psr-0": {"": "src/"}
}
}
我试图更改一些phpdoc注释并多次重置架构。
有人在教义上遇到过类似的问题吗?我希望得到一些提示,因为我什至不确定这个问题是由我的PHP代码文件引起的,还是由我正在使用的orm工具的某些错误配置引起的,或者可能是由我没有想到的某种原因引起的的
/**
* @Entity @Table(name="credentials")
*/
class Credentials
{
/** @Id @Column(type="integer") @GeneratedValue **/
protected $id;
/** @Column(type="string") **/
public $Email;
/** @Column(type="string") **/
public $Loginname;
/** @Column(type="string") **/
public $EntropyString;
/** @Column(type="string") **/
public $AccessToken;
public function __construct()
{
}
public function getId()
{
return $this->id;
}
}
以下是apache的完整回复:
致命错误:未被发现 原则\公共\持久性\映射\映射异常:类 “凭据”在以下位置不存在 F:\ XAMPP \ httpd.private \ src \ php \ vendor \ doctrine \ persistence \ lib \ Doctrine \ Common \ Persistence \ Mapping \ MappingException.php:93 堆栈跟踪:#0 F:\ XAMPP \ httpd.private \ src \ php \ vendor \ doctrine \ persistence \ lib \ Doctrine \ Common \ Persistence \ Mapping \ RuntimeReflectionService.php(24): 教义\ Common \ Persistence \ Mapping \ MappingException :: nonExistingClass('credentials')
1 F:\ XAMPP \ httpd.private \ src \ php \ vendor \ doctrine \ persistence \ lib \ Doctrine \ Common \ Persistence \ Mapping \ AbstractClassMetadataFactory.php(250):
Doctrine \ Common \ Persistence \ Mapping \ RuntimeReflectionService-> getParentClasses('credentials')
2 F:\ XAMPP \ httpd.private \ src \ php \ vendor \ doctrine \ persistence \ lib \ Doctrine \ Common \ Persistence \ Mapping \ AbstractClassMetadataFactory.php(283):
Doctrine \ Common \ Persistence \ Mapping \ AbstractClassMetadataFactory-> getParentClasses('credentials')
3 F:\ XAMPP \ httpd.private \ src \ php \ vendor \ doctrine \ orm \ lib \ Doctrine \ ORM \ Mapping \ ClassMetadat
在 F:\ XAMPP \ httpd.private \ src \ php \ vendor \ doctrine \ persistence \ lib \ Doctrine \ Common \ Persistence \ Mapping \ MappingException.php 在第93行
调用EntityManager的Find方法时发生错误:
$this->credentials = $this->entityManager->Find('credentials', $result[0]["id"]);
答案 0 :(得分:0)
将完全限定的类名添加到EntityManager的Find方法的调用后,不再发生异常:
$this->credentials = $this->entityManager->Find('Businessrelations\Database\Credentials', $result[0]["id"]);