Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Semantical Error] The annotation "@Symfony\Component\Validator\Tests\Constraints\NotBlank" in property Blog\ModelBundle\Entity\Post::$title does not exist, or could not be auto-loaded. #13932

Closed
ghost opened this issue Mar 15, 2015 · 2 comments

Comments

@ghost
Copy link

ghost commented Mar 15, 2015

On this module:

<?php

namespace Blog\ModelBundle\Entity;

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

/**
 * Post
 *
 * @ORM\Table()
 * @ORM\Entity
 */
class Post extends Timestampable
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=150)
     * @Assert\NotBlank
     */
    private $title;

    /**
     * @var string
     *
     * @ORM\Column(name="body", type="text")
     * @Assert\NotBlank
     */
    private $body;

    /**
     * @var Author
     *
     * @ORM\ManyToOne(targetEntity="Author", inversedBy="posts")
     * @ORM\JoinColumn(name="author_id", referencedColumnName="id", nullable=false)
     * @Assert\NotBlank
     */
    private $author;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set title
     *
     * @param string $title
     * @return Post
     */
    public function setTitle($title)
    {
        $this->title = $title;

        return $this;
    }

    /**
     * Get title
     *
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }

    /**
     * Set body
     *
     * @param string $body
     * @return Post
     */
    public function setBody($body)
    {
        $this->body = $body;

        return $this;
    }

    /**
     * Get body
     *
     * @return string
     */
    public function getBody()
    {
        return $this->body;
    }
}

I'm having this error when i try to update the schema:
php app/console doctrine:schema:update --force

------------------- Error ------------------
[Doctrine\Common\Annotations\AnnotationException]                                                                                                    
  [Semantical Error] The annotation "@Symfony\Component\Validator\Tests\Constraints\NotBlank" in property Blog\ModelBundle\Entity\Post::$title does n  
  ot exist, or could not be auto-loaded. 

Thank you in advance.

@jzawadzki
Copy link
Contributor

You use wrong import (you have linked to tests not to actual code):
type

use Symfony\Component\Validator\Constraints as Assert;

instead of

use Symfony\Component\Validator\Tests\Constraints as Assert;

@fabpot fabpot closed this as completed Mar 16, 2015
@ghost
Copy link
Author

ghost commented Mar 17, 2015

Thank You jzawadzki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants