0
我試圖發展自己的UniqueUserId發生器, 我需要的ID來爲這種格式:生成UniqueUserID與哈希
99fbf2be-d41b-4c1c-e44e-c1fde9dd4738
這是我的代碼:
<?php
namespace OKO\OKOUniqueUserId;
use Rhumsaa\Uuid\Uuid;
use Rhumsaa\Uuid\Exception\UnsatisfiedDependencyException;
class UniqueUserId
{
/**
* @var
*/
private $uuid;
/**
* @return Uuid
*/
public function generate()
{
try {
$this->uuid = Uuid::uuid4();
} catch (UnsatisfiedDependencyException $e) {
echo 'Error Generating User Unique ID';
}
return $this->uuid;
}
}
MY OUTPYT現在這個樣子:
object(Rhumsaa\Uuid\Uuid)#356 (1) { ["fields":protected]=> array(6) { ["time_low"]=> string(8) "d5a6efdf" ["time_mid"]=> string(4) "3f09" ["time_hi_and_version"]=> string(4) "416a" ["clock_seq_hi_and_reserved"]=> string(2) "b6" ["clock_seq_low"]=> string(2) "e8" ["node"]=> string(12) "7befe7820cb7" } }
但我還是會想到這一點:
25769c6c-d34d-4bfe-ba98-e0ee856f3e7a
THX
爲什麼不按照[RFC 4122](https://www.ietf。)生成適當的UUID(https://github.com/ramsey/uuid)。組織/ RFC/rfc4122.txt) –
喜歡哪一個..>? – John
確定通過作曲家安裝UUID庫後,它安裝在我的Symfony2項目的Vendor文件夾中如何在我的php類中使用它...? – John