Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ClassNotFoundException Symfony2验证程序_Class_Validation_Symfony_Exception - Fatal编程技术网

ClassNotFoundException Symfony2验证程序

ClassNotFoundException Symfony2验证程序,class,validation,symfony,exception,Class,Validation,Symfony,Exception,我在Symfony2.4中有一个自定义验证器 namespace My\Bundle\validation\Constraints; use Symfony\Component\Validator\Constraint; /** * @Annotation */ class CustomValidator extends Constraint { /** * @var str the message to display if violation */ public $message = "th

我在Symfony2.4中有一个自定义验证器

namespace My\Bundle\validation\Constraints;
use Symfony\Component\Validator\Constraint;
/**
* @Annotation
*/
class CustomValidator extends Constraint {
/**
* @var str the message to display if violation
*/
public $message = "the message";

/**
 * {@inheritdoc}
 */
public function validatedBy()
{
return 'my_validator_service';      
}

/**
* {@inheritdoc}
*/
public function getTargets()
{
return self::PROPERTY_CONSTRAINT;
}
}
现在,在另一个bundle FormType中:

.....
use My\Bundle\Validation\Constraints;

public function setDefaultOptions(OptionsResolverInterface $resolver)
{

 $collectionConstraint = new Assert\Collection(array(
 .......,
 'test' => array(
    new CustomValidator(),
),
 ........

 $resolver->setDefaults(array(
        'constraints' => $collectionConstraint,
        'data' => $data,
    ));
}
但我有一个例外:

ClassNotFoundException:试图从blabla\Type中的命名空间“My\Bundle\Validation\Constraints”加载类“CustomValidator”。是否需要从另一个命名空间“使用”它


你觉得怎么样?可能是一些琐碎的事情,但我不知道它可能是什么

也许您应该在中更改您的使用指令:

use My\Bundle\Validation\Constraints\CustomValidator;
好的,我找到了。 命名空间和用法是正确的,但Folder被称为Validator而不是Validation。
抱歉,我已经尝试了各种组合,使用
作为
,或者不同的名称。但是没有结果。