2

I am working on a new project in Symfony 5.3. I am using this command bin/console make:entity for creating entities.

This wizard automatically creates an entity with $id as primary key of type integer. I am prefering UUID instead of integer.

How I should change settings to get Entity like this?

Thank you

namespace App\Entity;
    
use App\Repository\EventRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator;
    
/**
 * @ORM\Entity(repositoryClass=EventRepository::class)
 */
class Event
{
    /**
     * @ORM\Id
     * @ORM\Column(type="uuid", unique=true)
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class=UuidGenerator::class)
     */
    private $id;
    
     ...
}

1 Answers1

1

There is no option to set the generated identifier strategy on make entity. You can see all available option using php bin/console make:entity -h

Also there are no configuration in doctrine.yaml file to define this.

It could be a good feature to add for current and next version

To request a new feature, you can create a new issue feature request type: https://github.com/symfony/symfony/issues/new/choose You will need a github account

Florent Cardot
  • 1,400
  • 1
  • 10
  • 19