Skip to content

Instantly share code, notes, and snippets.

@parijke
Created August 20, 2020 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parijke/21318d60d6f0e5d7b4e639edfa93efee to your computer and use it in GitHub Desktop.
Save parijke/21318d60d6f0e5d7b4e639edfa93efee to your computer and use it in GitHub Desktop.
Symfony Uid as primary identifier
<?php
namespace App\Entity\Traits;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
trait EntityIdTrait
{
/**
* @ORM\Id
* @ORM\Column(type="string", length=36, unique=true)
* @ORM\GeneratedValue(strategy="CUSTOM")
* @ORM\CustomIdGenerator(class="App\Entity\Generator\UuidGenerator")
*/
protected $id;
public function getId(): ?Uuid
{
return $this->id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment