gpt4 book ai didi

php - Doctrine2 ODM - [语义错误]

转载 作者:搜寻专家 更新时间:2023-10-31 21:15:46 28 4
gpt4 key购买 nike

我一直收到这个错误:

PHP Fatal error: Uncaught exception 'Doctrine\Common\Annotations\AnnotationException' with message '[Semantical Error] The annotation "@Document" in class Documents\Translation was never imported.' in /home/bmay/devel/svn/wwv/trunk/test_mongo_record/doctrine-mongodb-odm/lib/vendor/doctrine-mongodb-odm/lib/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationException.php:52

这里的代码很简单:

namespace Documents;

/** @Document */
class Translation
{
//private $string;
//private $date;

/** @String */
private $name;

public function setName($name) {
$this->name = $name;
}

}

最佳答案

注解用法在新版本中发生了变化。在你可以使用注解之前,Doctrine\ODM\MongoDB\Mapping\Annotations 应该用 use 导入:

namespace Documents;

use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;

/** @ODM\Document */
class Translation
{
/** @ODM\String */
private $name;
}

关于php - Doctrine2 ODM - [语义错误],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9157762/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com