Php 如何查找注册的文件批注名称空间
在我的symfony项目中,过去的编码器有这样的注释Php 如何查找注册的文件批注名称空间,php,symfony,doctrine-orm,annotations,Php,Symfony,Doctrine Orm,Annotations,在我的symfony项目中,过去的编码器有这样的注释 /MyBundle/constraint/Annotation/Check.php namespace Der\CpsBundle\Constraint\Annotation; use Symfony\Component\Validator\Constraint; class Check extends Constraint{ 现在symfony文档显示 如果要定义自己的注释,只需将它们分组到名称空间中,然后在AnnotationRe
/MyBundle/constraint/Annotation/Check.php
namespace Der\CpsBundle\Constraint\Annotation;
use Symfony\Component\Validator\Constraint;
class Check extends Constraint{
现在symfony文档显示
如果要定义自己的注释,只需将它们分组到名称空间中,然后在AnnotationRegistry中注册此名称空间。注释类必须包含具有文本@Annotation:
如何在哪个文件中注册该名称空间。我想知道如果使用Symfony2,那么所有注释都会自动注册(至少所有约束注释)。您只需为类添加注释,如下所示:
/** @Annotation */
class MyAnnotation extends Constraint {...}
当然,当您使用注释时,您需要导入它
use My\Namespace\Constraint\Annotation as Annotation
....
/** @Annotation\MyAnnotation() */
class Form { ... }