PHP code example of jop-software / doctrine-uuid-generators
1. Go to this page and download the library: Download jop-software/doctrine-uuid-generators library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jop-software / doctrine-uuid-generators example snippets
namespace App\Entity;
use App\Repository\EntityNameRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use JopSoftware\DoctrineUuidGenerators\UuidV4Generator;
use Symfony\Component\Uid\UuidV4;
#[ORM\Entity(repositoryClass: EntityNameRepository::class)]
class EntityName
{
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'CUSTOM')]
#[ORM\Column(type: "uuid", unique: true)]
#[ORM\CustomIdGenerator(class: UuidV4Generator::class)]
private UuidV4|null $id = null;
public function getId(): UuidV4|null
{
return $this->id;
}
}