T
T
Tarakkolya2014-07-04 22:48:39
symfony
Tarakkolya, 2014-07-04 22:48:39

What to do with [Semantical Error] symfony 2 error?

There is this code:

<?php 
namespace Test\TestBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="answers")
 */
class Answers{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    
    /**
    * @ORM\ManyToOne(targetEntity="QuestionAnswers", inversedBy="answers")
    **/
    protected $questionAnswer;
    
    
    /**
     * @ORM\Column(type="string", length=250)
     * @Assert\NotBlank()
     * @Assert\MinLength(5)
     * @Assert\MaxLength(250)
     */
    protected $answer;
    
    /**
     * @ORM\Column(type="boolean" ) 
     */
    protected $rightAnswer=false;}

command: php app/console doctrine:schema:update --force
swears like this:
[Doctrine\Common\Annotations\AnnotationException]                            
  [Semantical Error] The annotation "@Symfony\Component\Validator\Constraints  
  \MinLength" in property ForaSoft\TestBundle\Entity\Answers::$answer does no  
  t exist, or could not be auto-loaded.

Tell me, please, what could be the problem.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Makarov, 2014-07-04
@Tarakkolya

The MinLength class has been removed since version 2.3, I don't remember exactly. Instead, you should use the Length class with min or max keys.

/**
     * @ORM\Column(type="string", length=250)
     * @Assert\NotBlank()
     * @Assert\Length(min=5, max =250)
     */
    protected $answer;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question