ramsey/uuid
  • Introduction
    • What Is a UUID?
  • Getting Started
    • Requirements
    • Install With Composer
    • Using ramsey/uuid
  • RFC 9562 (formerly RFC 4122) UUIDs
    • Version 1: Gregorian Time
      • Providing a Custom Node
      • Generating a Random Node
      • What’s a Clock Sequence?
      • Privacy Concerns
    • Version 2: DCE Security
      • Domains
      • Custom and Random Nodes
      • Clock Sequence
      • Problems With Version 2 UUIDs
        • Privacy
        • Limited Uniqueness
        • Lossy Timestamps
    • Version 3: Name-based (MD5)
    • Version 4: Random
    • Version 5: Name-based (SHA-1)
      • Custom Namespaces
    • Version 6: Reordered Gregorian Time
      • Custom and Random Nodes
      • Clock Sequence
      • Version 1-to-6 Conversion
      • Ordered-time to Version 6 Conversion
      • Privacy Concerns
    • Version 7: Unix Epoch Time
      • Convert a Version 7 UUID to a ULID
    • Version 8: Custom Format
  • Nonstandard UUIDs
    • Version 6: Reordered Gregorian Time
    • Globally Unique Identifiers (GUIDs)
      • Converting GUIDs to UUIDs
    • Other Nonstandard UUIDs
  • Using In a Database
    • Storing As a String
    • Storing As Bytes
    • Using As a Primary Key
    • Using As a Unique Key
    • Insertion Order and Sorting
  • Customization
    • Ordered-time Codec
    • Timestamp-first COMB Codec
    • Using a Custom Calculator
    • Using a Custom Validator
    • Replace the Default Factory
  • Testing With UUIDs
    • Inject a UUID of a Specific Type
    • Returning Specific UUIDs From a Static Method
    • Mocking UuidInterface
  • Upgrading ramsey/uuid
    • Version 3 to 4
      • What’s New?
      • What’s Changed?
      • Uuid Static Methods
      • Changed Return Types
      • Deprecations
        • UuidInterface
        • Uuid
      • Interface Changes
        • UuidInterface
        • UuidFactoryInterface
        • Builder\UuidBuilderInterface
        • Converter\TimeConverterInterface
        • Provider\TimeProviderInterface
        • Provider\NodeProviderInterface
      • Constructor Changes
        • Uuid
        • Builder\DefaultUuidBuilder
        • Provider\Node\FallbackNodeProvider
        • Provider\Time\FixedTimeProvider
    • Version 2 to 3
  • FAQs
    • How do I fix “rhumsaa/uuid is abandoned” messages?
    • Why does ramsey/uuid use final?
      • But Why?
      • Overriding Behavior
      • Testing With UUIDs
  • Reference
    • Uuid
      • Uuid
        • Uuid::UUID_TYPE_TIME
        • Uuid::UUID_TYPE_DCE_SECURITY
        • Uuid::UUID_TYPE_HASH_MD5
        • Uuid::UUID_TYPE_RANDOM
        • Uuid::UUID_TYPE_HASH_SHA1
        • Uuid::UUID_TYPE_REORDERED_TIME
        • Uuid::UUID_TYPE_PEABODY
        • Uuid::UUID_TYPE_UNIX_TIME
        • Uuid::UUID_TYPE_CUSTOM
        • Uuid::NAMESPACE_DNS
        • Uuid::NAMESPACE_URL
        • Uuid::NAMESPACE_OID
        • Uuid::NAMESPACE_X500
        • Uuid::NIL
        • Uuid::DCE_DOMAIN_PERSON
        • Uuid::DCE_DOMAIN_GROUP
        • Uuid::DCE_DOMAIN_ORG
        • Uuid::RESERVED_NCS
        • Uuid::RFC_4122
        • Uuid::RFC_9562
        • Uuid::RESERVED_MICROSOFT
        • Uuid::RESERVED_FUTURE
        • Uuid::uuid1
        • Uuid::uuid2
        • Uuid::uuid3
        • Uuid::uuid4
        • Uuid::uuid5
        • Uuid::uuid6
        • Uuid::uuid7
        • Uuid::uuid8
        • Uuid::fromString
        • Uuid::fromBytes
        • Uuid::fromInteger
        • Uuid::fromDateTime
        • Uuid::isValid
        • Uuid::setFactory
    • UuidInterface
      • UuidInterface
        • UuidInterface::compareTo()
        • UuidInterface::equals()
        • UuidInterface::getBytes()
        • UuidInterface::getFields()
        • UuidInterface::getHex()
        • UuidInterface::getInteger()
        • UuidInterface::getUrn()
        • UuidInterface::toString()
        • UuidInterface::__toString()
    • Fields\FieldsInterface
      • FieldsInterface
        • FieldsInterface::getBytes()
    • Rfc4122\UuidInterface
      • UuidInterface
        • UuidInterface::getFields()
    • Rfc4122\FieldsInterface
      • FieldsInterface
        • FieldsInterface::getClockSeq()
        • FieldsInterface::getClockSeqHiAndReserved()
        • FieldsInterface::getClockSeqLow()
        • FieldsInterface::getNode()
        • FieldsInterface::getTimeHiAndVersion()
        • FieldsInterface::getTimeLow()
        • FieldsInterface::getTimeMid()
        • FieldsInterface::getTimestamp()
        • FieldsInterface::getVariant()
        • FieldsInterface::getVersion()
        • FieldsInterface::isNil()
    • Rfc4122\UuidV1
      • UuidV1
        • UuidV1::getDateTime()
    • Rfc4122\UuidV2
      • UuidV2
        • UuidV2::getDateTime()
        • UuidV2::getLocalDomain()
        • UuidV2::getLocalDomainName()
        • UuidV2::getLocalIdentifier()
    • Rfc4122\UuidV3
      • UuidV3
    • Rfc4122\UuidV4
      • UuidV4
    • Rfc4122\UuidV5
      • UuidV5
    • Rfc4122\UuidV6
      • UuidV6
        • UuidV6::getDateTime()
        • UuidV6::toUuidV1()
        • UuidV6::fromUuidV1
    • Rfc4122\UuidV7
      • UuidV7
        • UuidV7::getDateTime()
    • Rfc4122\UuidV8
      • UuidV8
    • Guid\Fields
      • Fields
    • Guid\Guid
      • Guid
        • Guid::getFields()
    • Nonstandard\Fields
      • Fields
    • Nonstandard\Uuid
      • Uuid
        • Uuid::getFields()
    • Nonstandard\UuidV6
      • UuidV6
        • UuidV6::getDateTime()
        • UuidV6::toUuidV1()
        • UuidV6::fromUuidV1
    • UuidFactoryInterface
      • UuidFactoryInterface
        • UuidFactoryInterface::getValidator()
        • UuidFactoryInterface::uuid1()
        • UuidFactoryInterface::uuid2()
        • UuidFactoryInterface::uuid3()
        • UuidFactoryInterface::uuid4()
        • UuidFactoryInterface::uuid5()
        • UuidFactoryInterface::uuid6()
        • UuidFactoryInterface::fromString()
        • UuidFactoryInterface::fromBytes()
        • UuidFactoryInterface::fromInteger()
        • UuidFactoryInterface::fromDateTime()
    • Types
      • TypeInterface
        • TypeInterface::toString()
        • TypeInterface::__toString()
      • NumberInterface
        • NumberInterface::isNegative()
      • Decimal
      • Hexadecimal
      • Integer
      • Time
        • Time::getSeconds()
        • Time::getMicroseconds()
    • Exceptions
      • UuidExceptionInterface
      • BuilderNotFoundException
      • DateTimeException
      • DceSecurityException
      • InvalidArgumentException
      • InvalidBytesException
      • InvalidUuidStringException
      • NameException
      • NodeException
      • RandomSourceException
      • TimeSourceException
      • UnableToBuildUuidException
      • UnsupportedOperationException
    • Helper Functions
    • Predefined Namespaces
    • Calculators
      • CalculatorInterface
        • CalculatorInterface::add()
        • CalculatorInterface::subtract()
        • CalculatorInterface::multiply()
        • CalculatorInterface::divide()
        • CalculatorInterface::fromBase()
        • CalculatorInterface::toBase()
        • CalculatorInterface::toHexadecimal()
        • CalculatorInterface::toInteger()
      • RoundingMode
        • RoundingMode::UNNECESSARY
        • RoundingMode::UP
        • RoundingMode::DOWN
        • RoundingMode::CEILING
        • RoundingMode::FLOOR
        • RoundingMode::HALF_UP
        • RoundingMode::HALF_DOWN
        • RoundingMode::HALF_CEILING
        • RoundingMode::HALF_FLOOR
        • RoundingMode::HALF_EVEN
    • Validators
      • ValidatorInterface
        • ValidatorInterface::getPattern()
        • ValidatorInterface::validate()
      • GenericValidator
      • Validator
  • Copyright
ramsey/uuid
  • Copyright
  • Edit on GitHub

Copyright

Copyright © 2012-2025 Ben Ramsey and contributors.

Documentation for ramsey/uuid is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.

ramsey/uuid is open source software: you can distribute it and/or modify it under the terms of the MIT License (the “License”). You may not use ramsey/uuid except in compliance with the License.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You should have received a copy of the MIT License along with this program. If not, see https://opensource.org/license/mit/.

Previous

© Copyright 2012-2025, Ben Ramsey.