You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// $uuid is an instance of Symfony\Component\Uid\UuidV3
70
+
$uuid = Uuid::v3($namespace, $name);
71
+
72
+
These are the default namespaces defined by the standard:
73
+
74
+
* ``Uuid::NAMESPACE_DNS`` if you are generating UUIDs for `DNS entries <https://en.wikipedia.org/wiki/Domain_Name_System>`__
75
+
* ``Uuid::NAMESPACE_URL`` if you are generating UUIDs for `URLs <https://en.wikipedia.org/wiki/URL>`__
76
+
* ``Uuid::NAMESPACE_OID`` if you are generating UUIDs for `OIDs (object identifiers) <https://en.wikipedia.org/wiki/Object_identifier>`__
77
+
* ``Uuid::NAMESPACE_X500`` if you are generating UUIDs for `X500 DNs (distinguished names) <https://en.wikipedia.org/wiki/X.500>`__
78
+
79
+
**UUID v4** (random)
80
+
Generates a random UUID (`read UUIDv4 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-4>`__).
81
+
Because of its randomness, it ensures uniqueness across distributed systems
82
+
without the need for a central coordinating entity. It's privacy-friendly
83
+
because it doesn't contain any information about where and when it was generated::
84
+
85
+
use Symfony\Component\Uid\Uuid;
86
+
87
+
// $uuid is an instance of Symfony\Component\Uid\UuidV4
88
+
$uuid = Uuid::v4();
89
+
90
+
**UUID v5** (name-based, SHA-1)
91
+
It's the same as UUIDv3 (explained above) but it uses ``sha1`` instead of
92
+
``md5`` to hash the given namespace and name (`read UUIDv5 spec <https://datatracker.ietf.org/doc/html/draft-ietf-uuidrev-rfc4122bis#name-uuid-version-5>`__).
93
+
This makes it more secure and less prone to hash collisions.
94
+
95
+
**UUID v6** (reordered time-based)
96
+
It rearranges the time-based fields of the UUIDv1 to make it lexicographically
97
+
sortable (like :ref:`ULIDs <ulid>`). It's more efficient for database indexing
0 commit comments