Usar UUID en Entity API Platform
Ir a la navegación
Ir a la búsqueda
Instalar UUID
composer require symfony/uid
Usar UUID en una propiedad en un Entity
<?php namespace App\Entity; use ApiPlatform\Metadata\ApiResource; use App\Repository\PlayerRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: PlayerRepository::class)] #[ApiResource] class Player { #[ORM\Id] #[ORM\Column(type: UuidType::NAME, unique: true)] #[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] private ?Uuid $id; public function getId(): ?Uuid { return $this->id; }
}