如何找到在哪个文件注释命名空间中注册


How can i find in which file annotation name space is registered

在我的symfony项目中,过去的编码器有这样的注释

/MyBundle/constraint/Annotation/Check.php

namespace Der'CpsBundle'Constraint'Annotation;
use Symfony'Component'Validator'Constraint;
class Check extends Constraint{

现在symfony文档说

http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html

如果要定义自己的注释,只需将它们分组到命名空间中,并在 AnnotationRegistry 中注册此命名空间即可。注释类必须包含一个类级文档块,其中包含文本@Annotation:

如何在哪个文件中注册该命名空间。 我想知道

如果你使用Symfony2,那么你所有的注解都会自动注册(至少是所有的约束注解)。您只需要像这样为类添加注释:

/** @Annotation */
class MyAnnotation extends Constraint {...}

当然,当您使用注释时,您需要导入它

use My'Namespace'Constraint'Annotation as Annotation
....
/** @Annotation'MyAnnotation() */
class Form { ... }