doctrine-extensions / DoctrineExtensions

Doctrine2 behavioral extensions, Translatable, Sluggable, Tree-NestedSet, Timestampable, Loggable, Sortable
MIT License
4.03k stars 1.27k forks source link

Fatal error: Uncaught Doctrine\Common\Annotations\AnnotationException #2179

Closed JulianaApolo closed 1 year ago

JulianaApolo commented 3 years ago

Fatal error: Uncaught Doctrine\Common\Annotations\AnnotationException: [Semantical Error] The annotation "@Gedmo\Mapping\Annotation\SoftDeleteable" in class Models\Brand was never imported. Did you maybe forget to add a "use" statement for this annotation? in /var/www/html/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php on line 39

<?php
namespace Models;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation AS Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Models\Model;

/**
 * @ORM\Entity
 * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
 * @ORM\HasLifecycleCallbacks
 * @ORM\Table(name="brands")
 */
class Brand extends BaseModel
{

Composer (Composer version 2.0-dev):

"require": {
        "php": "7.3.*",
        "ext-curl": "*",
        "ext-json": "*",
        "vlucas/phpdotenv": "2.6.5",
        "doctrine/orm": "^2.7",
        "fzaninotto/faker": "^1.9",
        "gedmo/doctrine-extensions": "^3.0"
    },
AkenRoberts commented 3 years ago

In your error message, the @gedmo is lowercase. Is that the actual error message? PHP is case-sensitive with namespaces and class names.

phansys commented 2 years ago

@JulianaApolo, could you please confirm if you still are experiencing this issue?

pluc commented 2 years ago

I am experiencing it.

namespace Models;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;

class Folder  {
    /**
     * @Gedmo\Translatable
     * @ORM\Column(name="name", type="string")
     */
    private $name;
}

Results in:

  [Semantical Error] The annotation "@Gedmo\Mapping\Annotation\Translatable" in property Mode  
  ls\Folder::$name was never imported. Did you maybe forget to add a "use" statement for this annotation?

This is with ^3.3. The same thing happen if you explicitly use Gedmo\Mapping\Annotation\Translatable.

Noext commented 2 years ago

try composer dump-autoload

thunder413 commented 2 years ago

same issue here

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.