jop-software/doctrine-uuid-generators

为您的 doctrine 模型生成 UUID

v2.0.0 2024-03-04 20:22 UTC

This package is auto-updated.

Last update: 2024-09-04 21:20:20 UTC


README

Doctrine UUID 生成器

为您的 doctrine 实体生成 UUID

CI CI

安装

composer require jop-software/doctrine-uuid-generators

使用

您可以在 CustomIdGenerator 注解中使用所有生成器。

<?php

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;
    }
}

可用生成器

版本 3 和 5 目前未实现,因为它们基于命名空间,而在 CustomIdGenerator 注解中目前没有方法传递这样的命名空间到生成器。

版本

专业支持

提供专业支持。请联系 support@jop-software.de 获取更多信息。

许可证

本项目采用 MIT 许可证

© 2022-2024, jop-software Inh. Johannes Przymusinski