我知道有类似https://github.com/ramsey/uuid之类的工具来生成UUID,但我不使用作曲家,而是想在我的登录控制器中生成UUID。
您可以使用此:
它使用随机字节,并使用vsprintf函数将它们放在正确的位置。
Random bytes
$UUID = vsprintf( '%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex(random_bytes(16)), 4) );