Error: The annotation does not exist #6520

Closed
opened 2026-01-22 15:34:27 +01:00 by admin · 1 comment
Owner

Originally created by @ad-test on GitHub (Aug 7, 2020).

I created a project, where the entities have annotations from both Doctrine\ORM\Mapping and MyLib\Annotation, like this:

<?php

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use MyLib\Annotation as MA;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User
{

    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue
     * @MA\Example
     */
    public $id;

    /**
     * @ORM\Column(type="string")
     */
    public $name;

}

Unfortunately I get this error, if I try to run orm:schema-tool:update:

In AnnotationException.php line 54:

  [Semantical Error] The annotation "@MyLib\Annotation\Example" in property App\Entity\User::$id does not exist,
   or could not be auto-loaded.

I created a minimal reproducible example project, it can be found here: https://github.com/ad-test/doctrine-annotation-bug

Originally created by @ad-test on GitHub (Aug 7, 2020). I created a project, where the entities have annotations from both `Doctrine\ORM\Mapping` and `MyLib\Annotation`, like this: ```php <?php namespace App\Entity; use Doctrine\ORM\Mapping as ORM; use MyLib\Annotation as MA; /** * @ORM\Entity * @ORM\Table(name="users") */ class User { /** * @ORM\Id * @ORM\Column(type="integer") * @ORM\GeneratedValue * @MA\Example */ public $id; /** * @ORM\Column(type="string") */ public $name; } ``` Unfortunately I get this error, if I try to run `orm:schema-tool:update`: ``` In AnnotationException.php line 54: [Semantical Error] The annotation "@MyLib\Annotation\Example" in property App\Entity\User::$id does not exist, or could not be auto-loaded. ``` I created a minimal reproducible example project, it can be found here: https://github.com/ad-test/doctrine-annotation-bug
admin closed this issue 2026-01-22 15:34:27 +01:00
Author
Owner

@SenseException commented on GitHub (Aug 8, 2020):

https://www.doctrine-project.org/projects/doctrine-annotations/en/1.10/annotations.html

If this is not an annotation relevant for Doctrine ORM and needs to be ignored, you'll have to tell Doctrine Annotations to ignore it. Otherwise it needs to be registered.

@SenseException commented on GitHub (Aug 8, 2020): https://www.doctrine-project.org/projects/doctrine-annotations/en/1.10/annotations.html If this is not an annotation relevant for Doctrine ORM and needs to be ignored, you'll have to tell Doctrine Annotations to ignore it. Otherwise it needs to be registered.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6520