我一直收到这个错误:
PHP致命错误:未捕获的异常 带有消息的'Doctrine \ Common \ Annotations \ AnnotationException' '[语义错误]类中的注释“@Document” Documents \ Translation从未导入。在 /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;
}
}
答案 0 :(得分:2)
新版本中的注释用法已更改。您必须先使用Doctrine\ODM\MongoDB\Mapping\Annotations
导入use
:
namespace Documents;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
/** @ODM\Document */
class Translation
{
/** @ODM\String */
private $name;
}