Home > Software engineering >  Symfony/Doctrine: entity appears invalid / not shown. Why?
Symfony/Doctrine: entity appears invalid / not shown. Why?

Time:01-30

I have the following entity:

<?php

namespace App\Entity\Geo;

use Doctrine\ORM\Mapping as ORM;

/*
 * @ORM\Entity(repositoryClass="App\Repository\Geo\CityRepository")
 * @ORM\Table(name="geo_cities")
 */
class City
{
  /**
   * @ORM\Id()
   * @ORM\GeneratedValue()
   * @ORM\Column(type="integer")
   */
  protected ?int $id = null;

  /**
   * Name of the city
   *
   * @ORM\Column(type="string", length=50, nullable=false)
   */
  protected string $name;

  /**
   * Addition for name of city
   *
   * @ORM\Column(type="string", length=20, nullable=false)
   */
  protected ?string $name_more = null;

  // Setters and getters
}

This entity is considered as invalid in Symfony console.

When I execute php bin/console doctrine:mapping:info, it is not listed.

I tried to rename entity, the namespace, remove fields, add fields but in all cases, the entity is not valid.

Any idea ?

Note: I have another entity with same structure and it is valid for doctrine.

CodePudding user response:

It's missing one * here

/*
 * @ORM\Entity(repositoryClass="App\Repository\Geo\CityRepository")
 * @ORM\Table(name="geo_cities")
 */
  • Related