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 does not exist, or could not be auto-loaded. #1402

Closed
vslinko opened this issue Jun 22, 2011 · 15 comments
Closed

Comments

@vslinko
Copy link

vslinko commented Jun 22, 2011

This model

<?php

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

/**
 * @ORM\Entity
 */
class Order
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @Assert\NotBlank()
     */
    public $date;

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getId()
    {
        return $this->id;
    }
}

raise this error

[Semantical Error] The annotation "@Symfony\Component\Validator\Constraints\NotBlank" in property Order::$date does not exist, or could not be auto-loaded.

This is because DocParser->autoloadAnnotations is false by default. How can I fix this?

@stloyd
Copy link
Contributor

stloyd commented Jun 22, 2011

http://symfony.com/doc/2.0/book/validation.html#configuration

framework:
    validation: { enabled: true, enable_annotations: true }

@vslinko
Copy link
Author

vslinko commented Jun 22, 2011

Already configured.

@stof
Copy link
Member

stof commented Jun 22, 2011

It seems like you are using Doctrine Common master instead of the 3.0.x branch

@vslinko
Copy link
Author

vslinko commented Jun 22, 2011

Thank you, @stof

@vslinko vslinko closed this as completed Jun 22, 2011
@matiasmm
Copy link

Thank you, i've asked the same in the symfony forum, and now i posted the answer: http://forum.symfony-project.org/viewtopic.php?uid=5995&f=23&t=35800&start=0

@scr4tchy
Copy link

Hello,

I wanted to upgrade from RC2 to RC4-5
But have the same issue with a fresh install of Symfony2 RC4 and same with Git Symfony.

And the solution posted at http://forum.symfony-project.org/viewtopic.php?uid=5995&f=23&t=35800&start=0 didnt work..

@vslinko
Copy link
Author

vslinko commented Jul 14, 2011

@scr4tchy
Copy link

Hello,

Thanks vslinko ! To Closed.

@rehan02
Copy link

rehan02 commented Sep 6, 2017

[Semantical Error] The annotation "@doctrine\ORM\Mapping\customerNumber" in property AppBundle\Entity\Customer::$customerNumber does not exist, or could not be auto-loaded.
I'm getting the same error.. I checked all the codes but still not able to fix this error.. and codes to display MYSQL data does not work...

@NicoHaase
Copy link
Contributor

@rehan02: is there anything you are asking for?

@mohsen-farahani
Copy link

ok

@dnm127
Copy link

dnm127 commented Nov 8, 2017

@stof hello, i have the same problem, i've already tried your solution but it doesnt' work

@joeDaigle
Copy link

In case anyone else has this issue, with Symfony 3.3, after hours of searching...
In all my infinite genius, I had forward-slash in Assert/NotBlank, where a back-slash is the ticket!

@TaktakTaktouk
Copy link

TaktakTaktouk commented Nov 22, 2017

same issue! I use Symfony 3.3 my entity start like that

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * 
 * 
 * @ORM\Entity(repositoryClass="AppBundle\Repository\CityRepository")
 * @ORM\Table(name="city")
 */
class City
{
    /**
     * @var int
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

   

And symfony tell me that he can"t find annotations

[2017-11-22 21:01:38] request.CRITICAL: Uncaught PHP Exception Doctrine\Common\Annotations\AnnotationException: "[Semantical Error] The annotation "@Doctrine\ORM\Mapping\Entity" in class AppBundle\Entity\City does not exist, or could not be auto-loaded." at /htdocs/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php line 54 {"exception":"[object] (Doctrine\\Common\\Annotations\\AnnotationException(code: 0): [Semantical Error] The annotation \"@Doctrine\\ORM\\Mapping\\Entity\" in class AppBundle\\Entity\\City does not exist, or could not be auto-loaded. at /htdocs/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54)"} []

@darius-v
Copy link

@joeDaigle - you are genius. Same with 2.8 symfony. There should be normal error message - so that it would be clear that slash is in wrong direction!

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