Skip to content
Advertisement

Symfony – Undefined type ‘DoctrineORMMappingEntity

I got many errors similar to this in topic after created entities. Dont’t know why cuz use tag seems correct. Using symfony 6.1.

Here is my model:

    namespace AppEntity;

    use AppRepositoryMovieRepository;
    use DoctrineCommonCollectionsArrayCollection;
    use DoctrineCommonCollectionsCollection;
    use DoctrineORMMapping as ORM;

    #[ORMEntity(repositoryClass: MovieRepository::class)]
    class Movie
    {
      #[ORMId]
      #[ORMGeneratedValue]
      #[ORMColumn(type: 'integer')]
      private $id;
    }

Advertisement

Answer

Instead of this

use DoctrineORMMapping as ORM;

#[ORMEntity(repositoryClass: MovieRepository::class)]
class Movie
{
#[ORMId]
#[ORMGeneratedValue]
#[ORMColumn(type: 'integer')]
private $id;

try that

use DoctrineORMMappingColumn;
use DoctrineORMMappingEntity;
use DoctrineORMMappingGeneratedValue;
use DoctrineORMMappingId;

#[Entity(repositoryClass: MovieRepository::class)]
class Movie
{
    #[Id, GeneratedValue, Column(type: 'integer')]
    private int $id;
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement