ramsey/uuid
A PHP library for generating and working with universally unique identifiers (UUIDs).
4.9.3
775M downloads/mo
#39 most downloaded on composer
ramsey/uuid
What this package is like to depend on
Last release 2 months ago
18 Jun 2026
Release timing varies
gaps range from 2 weeks to 13 months
Nearly every release is documented
notes for 81 of 81 stable releases
Nothing withdrawn
no release was ever pulled
14 years old
92 releases · first in 2012
3 releases in the last 12 months
see the full history below
Release timeline
92 releases · Jul 2012 to Jun 2026Releases
latest 60 of 92-
4.9.318 Jun 2026Release notes
Open source →Fixed
- Upgrade brick/math to support versions
^0.14to^0.17; fixed in #638. - Add support for brick/match
^0.18.
New Contributors
Full Changelog: 4.9.2...4.9.3
Release notes
Open source →Fixed
- Upgrade brick/math to support versions
^0.14to^0.17; fixed in #638. - Add support for brick/math
^0.18.
- Upgrade brick/math to support versions
-
4.9.214 Dec 2025Release notes
Open source →Fixed
- Remove explicit
(int)cast to avoid float-string cast warnings in PHP 8.5. - Bump the lowest supported version of brick/math to
^0.8.16from^0.8.8. ramsey/uuid had been usingBigInteger::toBytes()inUnixTimeGenerator(for version 7 UUIDs) since v4.6.0, but it wasn't added to brick/math until v0.8.16.
Full Changelog: 4.9.1...4.9.2
Release notes
Open source →Fixed
- Remove explicit
(int)cast to avoid float-string cast warnings in PHP 8.5. - Bump the lowest supported version of brick/math to
^0.8.16from^0.8.8. ramsey/uuid had been usingBigInteger::toBytes()inUnixTimeGenerator(for version 7 UUIDs) since v4.6.0, but it wasn't added to brick/math until v0.8.16.
- Remove explicit
-
4.9.104 Sep 2025Release notes
Open source →Fixed
- Allow brick/math version
^0.14; fixed in #617. - Default to
microtime()instead ofDateTimeImmutableinRamsey\Uuid\Generator\UnixTimeGenerator.
New Contributors
Full Changelog: 4.9.0...4.9.1
Release notes
Open source →Fixed
- Allow brick/math version
^0.14; fixed in #617. - Default to
microtime()instead ofDateTimeImmutableinRamsey\Uuid\Generator\UnixTimeGenerator.
- Allow brick/math version
-
4.9.025 Jun 2025Release notes
Open source →Added
- Add new
@pureannotations to the following (#605):Ramsey\Uuid\Codec\CodecInterface::encode()Ramsey\Uuid\Codec\CodecInterface::encodeBinary()Ramsey\Uuid\Codec\CodecInterface::decode()Ramsey\Uuid\Codec\CodecInterface::decodeBytes()Ramsey\Uuid\Fields\FieldsInterface::getBytes()Ramsey\Uuid\Math\CalculatorInterface::add()Ramsey\Uuid\Math\CalculatorInterface::subtract()Ramsey\Uuid\Math\CalculatorInterface::multiply()Ramsey\Uuid\Math\CalculatorInterface::divide()Ramsey\Uuid\Math\CalculatorInterface::fromBase()Ramsey\Uuid\Math\CalculatorInterface::toBase()Ramsey\Uuid\Math\CalculatorInterface::toHexadecimal()Ramsey\Uuid\Math\CalculatorInterface::toInteger()Ramsey\Uuid\Nonstandard\UuidRamsey\Uuid\Rfc4122\Fields::isMax()Ramsey\Uuid\Rfc4122\FieldsInterface::getVersion()Ramsey\Uuid\Rfc4122\FieldsInterface::isNil()Ramsey\Uuid\Type\Time::getSeconds()Ramsey\Uuid\Type\Time::getMicroseconds()Ramsey\Uuid\Type\TypeInterface::toString()Ramsey\Uuid\UuidInterface::getBytes()Ramsey\Uuid\UuidInterface::toString()Ramsey\Uuid\Validator\ValidatorInterface::validate()
Fixed
- Restore the
@pureannotations that were removed in 4.8.0 (#603).
Full Changelog: 4.8.1...4.9.0
Release notes
Open source →Added
- Add new
@pureannotations to the following (#605):Ramsey\Uuid\Codec\CodecInterface::encode()Ramsey\Uuid\Codec\CodecInterface::encodeBinary()Ramsey\Uuid\Codec\CodecInterface::decode()Ramsey\Uuid\Codec\CodecInterface::decodeBytes()Ramsey\Uuid\Fields\FieldsInterface::getBytes()Ramsey\Uuid\Math\CalculatorInterface::add()Ramsey\Uuid\Math\CalculatorInterface::subtract()Ramsey\Uuid\Math\CalculatorInterface::multiply()Ramsey\Uuid\Math\CalculatorInterface::divide()Ramsey\Uuid\Math\CalculatorInterface::fromBase()Ramsey\Uuid\Math\CalculatorInterface::toBase()Ramsey\Uuid\Math\CalculatorInterface::toHexadecimal()Ramsey\Uuid\Math\CalculatorInterface::toInteger()Ramsey\Uuid\Nonstandard\UuidRamsey\Uuid\Rfc4122\Fields::isMax()Ramsey\Uuid\Rfc4122\FieldsInterface::getVersion()Ramsey\Uuid\Rfc4122\FieldsInterface::isNil()Ramsey\Uuid\Type\Time::getSeconds()Ramsey\Uuid\Type\Time::getMicroseconds()Ramsey\Uuid\Type\TypeInterface::toString()Ramsey\Uuid\UuidInterface::getBytes()Ramsey\Uuid\UuidInterface::toString()Ramsey\Uuid\Validator\ValidatorInterface::validate()
Fixed
- Restore the
@pureannotations that were removed in 4.8.0 (#603).
- Add new
-
4.8.101 Jun 2025Release notes
Open source →Fixed
- This tagged release ensures the stable documentation build matches the current stable release.
Full Changelog: 4.8.0...4.8.1
Release notes
Open source →Fixed
- This tagged release ensures the stable documentation build matches the current stable release.
-
4.8.001 Jun 2025Release notes
Open source →Deprecated
The following will be removed in ramsey/uuid 5.0.0:
Ramsey\Uuid\Codec\OrderedTimeCodecis deprecated; please migrate to version 6 UUIDs.Ramsey\Uuid\Codec\TimestampFirstCombCodecis deprecated; please migrate to version 7 UUIDs.Ramsey\Uuid\Codec\TimestampLastCombCodecis deprecated; please useRamsey\Uuid\Codec\StringCodecinstead.Ramsey\Uuid\Generator\CombGeneratoris deprecated; please migrate to version 7 UUIDs.
Fixed
- Allow brick/math version
^0.13; fixed in #589. - Update call to
str_getcsv()to avoid deprecation notice in PHP 8.4; fixed in #590. - Hexadecimal is never an empty string; fixed in #593.
- Update docblocks for
Uuid::fromBytes(),Uuid::fromString(),Uuid::fromDateTime(),Uuid::fromHexadecimal(), andUuid::fromInteger()to note that each can throwInvalidArgumentException, addressing PHPStan errors occurring at call sites; fixed in #552. getVariant()forMaxUuidnow correctly returnsUuid::RESERVED_FUTURE, as specified in RFC 9562, section 5.10.getVariant()forNilUuidnow correctly returnsUuid::RESERVED_NCS, as specified in RFC 9562, section 5.9.
New Contributors
- @staabm made their first contribution in #552
- @Chris53897 made their first contribution in #568
- @jrfnl made their first contribution in #584
- @PNardman made their first contribution in #590
- @axlon made their first contribution in #593
- @derrabus made their first contribution in #589
Full Changelog: 4.7.6...4.8.0
Release notes
Open source →Deprecated
The following will be removed in ramsey/uuid 5.0.0:
Ramsey\Uuid\Codec\OrderedTimeCodecis deprecated; please migrate to version 6 UUIDs.Ramsey\Uuid\Codec\TimestampFirstCombCodecis deprecated; please migrate to version 7 UUIDs.Ramsey\Uuid\Codec\TimestampLastCombCodecis deprecated; please useRamsey\Uuid\Codec\StringCodecinstead.Ramsey\Uuid\Generator\CombGeneratoris deprecated; please migrate to version 7 UUIDs.
Fixed
- Allow brick/math version
^0.13; fixed in #589. - Update call to
str_getcsv()to avoid deprecation notice in PHP 8.4; fixed in #590. - Hexadecimal is never an empty string; fixed in #593.
- Update docblocks for
Uuid::fromBytes(),Uuid::fromString(),Uuid::fromDateTime(),Uuid::fromHexadecimal(), andUuid::fromInteger()to note that each can throwInvalidArgumentException, addressing PHPStan errors occurring at call sites; fixed in #552. getVariant()forMaxUuidnow correctly returnsUuid::RESERVED_FUTURE, as specified in RFC 9562, section 5.10.getVariant()forNilUuidnow correctly returnsUuid::RESERVED_NCS, as specified in RFC 9562, section 5.9.
-
4.7.627 Apr 2024 -
4.7.508 Nov 2023 -
4.7.415 Apr 2023 -
4.7.312 Jan 2023Release notes
Open source →Fixed
- The original 4.7.2 tag accidentally pointed to a commit in the 5.x branch. I have replaced the 4.7.2 tag with a new tag that points to the correct commit, but I am creating this tag to help notify users and automated processes who might have already updated to the bad 4.7.2 tag (#487).
Release notes
Open source →Fixed
- The original 4.7.2 tag accidentally pointed to a commit in the 5.x branch. I have replaced the 4.7.2 tag with a new tag that points to the correct commit, but I am creating this tag to help notify users and automated processes who might have already updated to the bad 4.7.2 tag.
-
4.7.212 Jan 2023Release notes
Open source →Fixed
- Amend Psalm assertion syntax on
Uuid::isValid()to prevent incorrect type inference (#486). - Re-tagged with the correct commit hash, since the first tag was pointing to a commit in the 5.x branch.
- Amend Psalm assertion syntax on
-
4.7.131 Dec 2022 -
4.7.019 Dec 2022Release notes
Open source →Added
- Add
Uuid::fromHexadecimal()andUuidFactory::fromHexadecimal(). These methods are not required by the interfaces.
Fixed
- Ignore MAC addresses consisting of all zeroes (i.e.,
00:00:00:00:00:00).
- Add
-
4.6.005 Nov 2022Release notes
Open source →Added
- Add support for version 8, Unix Epoch time UUIDs, as defined in
[draft-ietf-uuidrev-rfc4122bis-00, section 5.8][version8]. While still an
Internet-Draft, version 8 is stable and unlikely to change in any way that
breaks compatibility.
- Use
Ramsey\Uuid\Uuid::uuid8()to generate version 8 UUIDs. - Version 8 UUIDs are of type
Ramsey\Uuid\Rfc4122\UuidV8. - The constant
Ramsey\Uuid\Uuid::UUID_TYPE_CUSTOMexists for version 8 UUIDs.
- Use
Fixed
- Ensure monotonicity of version 7 UUIDs.
- Add support for version 8, Unix Epoch time UUIDs, as defined in
[draft-ietf-uuidrev-rfc4122bis-00, section 5.8][version8]. While still an
Internet-Draft, version 8 is stable and unlikely to change in any way that
breaks compatibility.
-
4.5.116 Sep 2022 -
4.5.015 Sep 2022Release notes
Open source →Added
- Promote version 6, reordered time UUIDs from the
Nonstandardnamespace to theRfc4122namespace. Version 6 UUIDs are defined in [draft-ietf-uuidrev-rfc4122bis-00, section 5.6][version6]. While still an Internet-Draft version 6 is stable and unlikely to change in any way that breaks compatibility. - Add support for version 7, Unix Epoch time UUIDs, as defined in
[draft-ietf-uuidrev-rfc4122bis-00, section 5.7][version7]. While still an
Internet-Draft, version 7 is stable and unlikely to change in any way that
breaks compatibility.
- Use
Ramsey\Uuid\Uuid::uuid7()to generate version 7 UUIDs. - Version 7 UUIDs are of type
Ramsey\Uuid\Rfc4122\UuidV7. - The constant
Ramsey\Uuid\Uuid::UUID_TYPE_UNIX_TIMEexists for version 7 UUIDs.
- Use
- Add
Ramsey\Uuid\Converter\Time\UnixTimeConverterandRamsey\Uuid\Generator\UnixTimeGeneratorto support version 7 UUID generation. - Add support for [max UUIDs][] through
Ramsey\Uuid\Uuid::MAXandRamsey\Uuid\Rfc4122\MaxUuid.
Changed
- The lowest version of brick/math allowed is now
^0.8.8.
Deprecated
The following will be removed in ramsey/uuid 5.0.0:
Ramsey\Uuid\Nonstandard\UuidV6is deprecated in favor ofRamsey\Uuid\Rfc4122\UuidV6.Ramsey\Uuid\Uuid::UUID_TYPE_PEABODY; useRamsey\Uuid\Uuid::UUID_TYPE_REORDERED_TIMEinstead.
Fixed
- For
Ramsey\Uuid\Uuid::isValid(), Psalm now asserts the UUID is a non-empty-string when it is valid. - Nil UUIDs are properly treated as RFC 4122 variants, and
getVariant()now returns a2when called on a nil UUID.
- Promote version 6, reordered time UUIDs from the
-
4.4.005 Aug 2022Release notes
Open source →Changed
- Allow brick/math 0.10.
- Remove dev dependency to moontoast/math.
- Un-deprecate
UuidInterface::getUrn().
-
4.3.127 Mar 2022Release notes
Open source →Deprecated
The following will be removed in ramsey/uuid 5.0.0:
Ramsey\Uuid\Generator\RandomLibAdapter
-
4.3.026 Mar 2022Release notes
Open source →Changed
- Remove support for PHP 7.2, 7.3, and 7.4. This is not a BC break, since Composer will do the right thing for your environment and select a compatible version of this library.
- Require
ext-ctypeextension. For applications that run in environments where theext-ctypeis not present, please require a polyfill, such as symfony/polyfill-ctype. - Use
iterable<UuidBuilderInterface>instead ofBuilderCollectiontypes. - Use
iterable<NodeProviderInterface>instead ofNodeProviderCollectiontypes.
Deprecated
The following will be removed in ramsey/uuid 5.0.0:
Ramsey\Uuid\Builder\BuilderCollectionRamsey\Uuid\Provider\Node\NodeProviderCollection- Dependency on ramsey/collection
Fixed
- Support valid UUIDs in uppercase in
LazyUuidFromString.
-
4.2.325 Sep 2021 -
4.2.224 Sep 2021Release notes
Open source →Fixed
- Indicate support for PHP 8.1, using
~8.1.0to prevent installations on 8.2 until the library is ready.
- Indicate support for PHP 8.1, using
-
4.2.111 Aug 2021Release notes
Open source →Fixed
- Fix soft BC break with
Uuid::fromString()signature. The change fromstringtonon-empty-stringon the parameter annotation introduced a BC break for those using static analysis tools. This release reverts this change and provides an assertion to guard against empty strings. See ramsey/uuid#383.
- Fix soft BC break with
-
4.2.006 Aug 2021Release notes
Open source →Added
- Add
Ramsey\Uuid\Exception\UuidExceptionInterfacefor all ramsey/uuid exceptions to implement. See ramsey/uuid#340.
Fixed
- Fix serialization of UUIDs. See ramsey/uuid#361.
- Add
-
4.1.325 Sep 2021 -
4.1.224 Sep 2021 -
4.1.118 Aug 2020 -
4.1.028 Jul 2020Release notes
Open source →Changed
- Improve performance of
Uuid::fromString(),Uuid::fromBytes(),UuidInterface#toString(), andUuidInterface#getBytes(). See PR #324 for more information.
- Improve performance of
-
4.0.325 Sep 2021 -
4.0.224 Sep 2021 -
4.0.129 Mar 2020Release notes
Open source →Fixed
- Fix collection deserialization errors due to upstream
allowed_classesbeing set tofalse. For details, see ramsey/uuid#303 and ramsey/collection#47.
- Fix collection deserialization errors due to upstream
-
4.0.022 Mar 2020Release notes
Open source →Added
- Add support for version 6 UUIDs, as defined by http://gh.peabody.io/uuidv6/,
including the static method
Uuid::uuid6(), which returns aNonstandard\UuidV6instance. - Add ability to generate version 2 (DCE Security) UUIDs, including the static
method
Uuid::uuid2(), which returns anRfc4122\UuidV2instance. - Add classes to represent each version of RFC 4122 UUID. When generating new
UUIDs or creating UUIDs from existing strings, bytes, or integers, if the UUID
is an RFC 4122 variant, one of these instances will be returned:
Rfc4122\UuidV1Rfc4122\UuidV2Rfc4122\UuidV3Rfc4122\UuidV4Rfc4122\UuidV5Rfc4122\NilUuid
- Add classes to represent version 6 UUIDs, GUIDs, and nonstandard
(non-RFC 4122 variant) UUIDs:
Nonstandard\UuidV6Guid\GuidNonstandard\Uuid
- Add
Uuid::fromDateTime()to create version 1 UUIDs from instances of\DateTimeInterface. - The
\DateTimeInterfaceinstance returned byUuidInterface::getDateTime()(and nowRfc4122\UuidV1::getDateTime()) now includes microseconds, as specified by the version 1 UUID. - Add
Validator\ValidatorInterfaceandValidator\GenericValidatorto allow flexibility in validating UUIDs/GUIDs.- The default validator continues to validate UUID strings using the same relaxed validation pattern found in the 3.x series of ramsey/uuid.
- Introduce
Rfc4122\Validatorthat may be used for strict validation of RFC 4122 UUID strings. - Add ability to change the default validator used by
UuidthroughFeatureSet::setValidator(). - Add
getValidator()andsetValidator()toUuidFactory.
- Add
Provider\Node\StaticNodeProviderto assist in setting a custom static node value with the multicast bit set for version 1 UUIDs. - Add the following new exceptions:
Exception\BuilderNotFoundException- Thrown to indicate that no suitable UUID builder could be found.Exception\DateTimeException- Thrown to indicate that the PHP DateTime extension encountered an exception/error.Exception\DceSecurityException- Thrown to indicate an exception occurred while dealing with DCE Security (version 2) UUIDs.Exception\InvalidArgumentException- Thrown to indicate that the argument received is not valid. This extends the built-in PHP\InvalidArgumentException, so there should be no BC breaks with ramsey/uuid throwing this exception, if you are catching the PHP exception.Exception\InvalidBytesException- Thrown to indicate that the bytes being operated on are invalid in some way.Exception\NameException- Thrown to indicate that an error occurred while attempting to hash a namespace and name.Exception\NodeException- Thrown to indicate that attempting to fetch or create a node ID encountered an error.Exception\RandomSourceException- Thrown to indicate that the source of random data encountered an error.Exception\TimeSourceException- Thrown to indicate that the source of time encountered an error.Exception\UnableToBuildUuidException- Thrown to indicate a builder is unable to build a UUID.
- Introduce a
Builder\FallbackBuilder, used byFeatureSetto help decide whether to return aUuidorNonstandard\Uuidwhen decoding a UUID string or bytes. - Add
Rfc4122\UuidInterfaceto specifically represent RFC 4122 variant UUIDs. - Add
Rfc4122\UuidBuilderto build RFC 4122 variant UUIDs. This replaces the existingBuilder\DefaultUuidBuilder, which is now deprecated. - Introduce
Math\CalculatorInterfacefor representing calculators to perform arithmetic operations on integers. - Depend on brick/math for the
Math\BrickMathCalculator, which is the default calculator used by this library when math cannot be performed in native PHP due to integer size limitations. The calculator is configurable and may be changed, if desired. - Add
Converter\Number\GenericNumberConverterandConverter\Time\GenericTimeConverterwhich will use the calculator provided to convert numbers and time to values for UUIDs. - Introduce
Type\Hexadecimal,Type\Integer,Type\Decimal, andType\Timefor improved type-safety when dealing with arbitrary string values. - Add a
Type\TypeInterfacethat each of the ramsey/uuid types implements. - Add
Fields\FieldsInterfaceandRfc4122\FieldsInterfaceto define field layouts for UUID variants. The implementationsRfc4122\Fields,Guid\Fields, andNonstandard\Fieldsstore the 16-byte, binary string representation of the UUID internally, and these manage conversion of the binary string into the hexadecimal field values. - Introduce
Builder\BuilderCollectionandProvider\Node\NodeProviderCollection. These are typed collections for providing builders and node providers toBuilder\FallbackBuilderandProvider\Node\FallbackNodeProvider, respectively. - Add
Generator\NameGeneratorInterfaceto support alternate methods of generating bytes for version 3 and version 5 name-based UUID. By default, ramsey/uuid uses theGenerator\DefaultNameGenerator, which uses the standard algorithm this library has used since the beginning. You may choose to use the newGenerator\PeclUuidNameGeneratorto make use of the newuuid_generate_md5()anduuid_generate_sha1()functions in ext-uuid version 1.1.0.
Changed
- Set minimum required PHP version to 7.2.
- This library now works on 32-bit and 64-bit systems, with no degradation in functionality.
- By default, the following static methods will now return specific instance
types. This should not cause any BC breaks if typehints target
UuidInterface:Uuid::uuid1returnsRfc4122\UuidV1Uuid::uuid3returnsRfc4122\UuidV3Uuid::uuid4returnsRfc4122\UuidV4Uuid::uuid5returnsRfc4122\UuidV5
- Accept
Type\Hexadecimalfor the$nodeparameter forUuidFactoryInterface::uuid1(). This is in addition to theint|stringtypes already accepted, so there are no BC breaks.Type\Hexadecimalis now the recommended type to pass for$node. - Out of the box,
Uuid::fromString(),Uuid::fromBytes(), andUuid::fromInteger()will now return either anRfc4122\UuidInterfaceinstance or an instance ofNonstandard\Uuid, depending on whether the input contains an RFC 4122 variant UUID with a valid version identifier. Both implementUuidInterface, so BC breaks should not occur if typehints use the interface. - Change
Uuid::getFields()to return an instance ofFields\FieldsInterface. Previously, it returned an array of integer values (on 64-bit systems only). Uuid::getDateTime()now returns an instance of\DateTimeImmutableinstead of\DateTime.- Make the following changes to
UuidInterface:getHex()now returns aType\Hexadecimalinstance.getInteger()now returns aType\Integerinstance. TheType\Integerinstance holds a string representation of a 128-bit integer. You may then use a math library of your choice (bcmath, gmp, etc.) to operate on the string integer.getDateTime()now returns\DateTimeInterfaceinstead of\DateTime.- Add
__toString()method. - Add
getFields()method. It returns an instance ofFields\FieldsInterface.
- Add the following new methods to
UuidFactoryInterface:uuid2()uuid6()fromDateTime()fromInteger()getValidator()
- This library no longer throws generic exceptions. However, this should not
result in BC breaks, since the new exceptions extend from built-in PHP
exceptions that this library previously threw.
Exception\UnsupportedOperationExceptionis now descended from\LogicException. Previously, it descended from\RuntimeException.
- Change required constructor parameters for
Uuid:- Change the first required constructor parameter for
Uuidfromarray $fieldstoRfc4122\FieldsInterface $fields. - Add
Converter\TimeConverterInterface $timeConverteras the fourth required constructor parameter forUuid.
- Change the first required constructor parameter for
- Change the second required parameter of
Builder\UuidBuilderInterface::build()fromarray $fieldstostring $bytes. Rather than accepting an array of hexadecimal strings as UUID fields, thebuild()method now expects a byte string. - Add
Converter\TimeConverterInterface $timeConverteras the second required constructor parameter forRfc4122\UuidBuilder. This also affects the now-deprecatedBuilder\DefaultUuidBuilder, since this class now inherits fromRfc4122\UuidBuilder. - Add
convertTime()method toConverter\TimeConverterInterface. - Add
getTime()method toProvider\TimeProviderInterface. It replaces thecurrentTime()method. Provider\Node\FallbackNodeProvidernow accepts only aProvider\Node\NodeProviderCollectionas its constructor parameter.Provider\Time\FixedTimeProviderno longer accepts an array but accepts onlyType\Timeinstances.Provider\NodeProviderInterface::getNode()now returnsType\Hexadecimalinstead ofstring|false|null.Converter/TimeConverterInterface::calculateTime()now returnsType\Hexadecimalinstead ofarray. The value is the full UUID timestamp value (count of 100-nanosecond intervals since the Gregorian calendar epoch) in hexadecimal format.- Change methods in
NumberConverterInterfaceto accept and return string values instead ofmixed; this simplifies the interface and makes it consistent. Generator\DefaultTimeGeneratorno longer adds the variant and version bits to the bytes it returns. These must be applied to the bytes afterwards.- When encoding to bytes or decoding from bytes,
OrderedTimeCodecnow checks whether the UUID is an RFC 4122 variant, version 1 UUID. If not, it will throw an exception—InvalidArgumentExceptionwhen usingOrderedTimeCodec::encodeBinary()andUnsupportedOperationExceptionwhen usingOrderedTimeCodec::decodeBytes().
Deprecated
The following functionality is deprecated and will be removed in ramsey/uuid 5.0.0.
- The following methods from
UuidInterfaceandUuidare deprecated. Use their counterparts on theRfc4122\FieldsInterfacereturned byUuid::getFields().getClockSeqHiAndReservedHex()getClockSeqLowHex()getClockSequenceHex()getFieldsHex()getNodeHex()getTimeHiAndVersionHex()getTimeLowHex()getTimeMidHex()getTimestampHex()getVariant()getVersion()
- The following methods from
Uuidare deprecated. Use theRfc4122\FieldsInterfaceinstance returned byUuid::getFields()to get theType\Hexadecimalvalue for these fields. You may use the newMath\CalculatorInterface::toIntegerValue()method to convert theType\Hexadecimalinstances to instances ofType\Integer. This library providesMath\BrickMathCalculator, which may be used for this purpose, or you may use the arbitrary-precision arithmetic library of your choice.getClockSeqHiAndReserved()getClockSeqLow()getClockSequence()getNode()getTimeHiAndVersion()getTimeLow()getTimeMid()getTimestamp()
getDateTime()onUuidInterfaceandUuidis deprecated. Use this method only on instances ofRfc4122\UuidV1orNonstandard\UuidV6.getUrn()onUuidInterfaceandUuidis deprecated. It is available onRfc4122\UuidInterfaceand classes that implement it.- The following methods are deprecated and have no direct replacements. However,
you may obtain the same information by calling
UuidInterface::getHex()and splitting the return value in half.UuidInterface::getLeastSignificantBitsHex()UuidInterface::getMostSignificantBitsHex()Uuid::getLeastSignificantBitsHex()Uuid::getMostSignificantBitsHex()Uuid::getLeastSignificantBits()Uuid::getMostSignificantBits()
UuidInterface::getNumberConverter()andUuid::getNumberConverter()are deprecated. There is no alternative recommendation, so plan accordingly.Builder\DefaultUuidBuilderis deprecated; transition toRfc4122\UuidBuilder.Converter\Number\BigNumberConverteris deprecated; transition toConverter\Number\GenericNumberConverter.Converter\Time\BigNumberTimeConverteris deprecated; transition toConverter\Time\GenericTimeConverter.- The classes for representing and generating degraded UUIDs are deprecated.
These are no longer necessary; this library now behaves the same on 32-bit and
64-bit systems.
Builder\DegradedUuidBuilderConverter\Number\DegradedNumberConverterConverter\Time\DegradedTimeConverterDegradedUuid
- The
Uuid::UUID_TYPE_IDENTIFIERconstant is deprecated. UseUuid::UUID_TYPE_DCE_SECURITYinstead. - The
Uuid::VALID_PATTERNconstant is deprecated. UseValidator\GenericValidator::getPattern()orRfc4122\Validator::getPattern()instead.
Removed
- Remove the following bytes generators and recommend
Generator\RandomBytesGeneratoras a suitable replacement:Generator\MtRandGeneratorGenerator\OpenSslGeneratorGenerator\SodiumRandomGenerator
- Remove
Exception\UnsatisfiedDependencyException. This library no longer throws this exception. - Remove the method
Provider\TimeProviderInterface::currentTime(). UseProvider\TimeProviderInterface::getTime()instead.
- Add support for version 6 UUIDs, as defined by http://gh.peabody.io/uuidv6/,
including the static method
-
4.0.0-beta201 Mar 2020 pre-releaseNothing published for this version
-
4.0.0-beta127 Feb 2020 pre-releaseRelease notes
Open source →Added
- Add
ValidatorInterface::getPattern()to return the regular expression pattern used by the validator. - Add
v6()helper function for version 6 UUIDs.
Changed
- Set the pattern constants on validators as
private. Use thegetPattern()method instead. - Change the
$nodeparameter forUuidFactoryInterface::uuid6()to acceptnullorType\Hexadecimal. - Accept
Type\Hexadecimalfor the$nodeparameter forUuidFactoryInterface::uuid1(). This is in addition to theint|stringtypes already accepted, so there are no BC breaks.Type\Hexadecimalis now the recommended type to pass for$node.
Removed
- Remove
currentTime()method fromProvider\Time\FixedTimeProviderandProvider\Time\SystemTimeProvider; it had previously been removed fromProvider\TimeProviderInterface.
- Add
-
4.0.0-alpha523 Feb 2020 pre-releaseRelease notes
Open source →Added
- Introduce
Builder\BuilderCollectionandProvider\Node\NodeProviderCollection.
Changed
Builder\FallbackBuildernow accepts only aBuilder\BuilderCollectionas its constructor parameter.Provider\Node\FallbackNodeProvidernow accepts only aProvider\Node\NodeProviderCollectionas its constructor parameter.Provider\Time\FixedTimeProviderno longer accepts an array but accepts onlyType\Timeinstances.
- Introduce
-
4.0.0-alpha423 Feb 2020 pre-releaseRelease notes
Open source →Added
- Add a
Type\TypeInterfacethat each of the ramsey/uuid types implements. - Support version 6 UUIDs; see http://gh.peabody.io/uuidv6/.
Changed
- Rename
Type\IntegerValuetoType\Integer. It was originally namedIntegerValuebecause static analysis seesIntegerin docblock annotations and treats it as the nativeinttype.Integeris not a reserved word in PHP, so it should be namedIntegerfor consistency with other types in this library. When using it, a class alias prevents static analysis from complaining. - Mark
Guid\GuidandNonstandard\Uuidclasses asfinal. - Add
uuid6()method toUuidFactoryInterface.
Deprecated
Uuid::UUID_TYPE_IDENTIFIERis deprecated. UseUuid::UUID_TYPE_DCE_SECURITYinstead.Uuid::VALID_PATTERNis deprecated. UseValidator\GenericValidator::VALID_PATTERNinstead.
- Add a
-
4.0.0-alpha321 Feb 2020 pre-release -
4.0.0-alpha221 Feb 2020 pre-releaseRelease notes
Open source →Added
- Add
Uuid::fromDateTime()to create version 1 UUIDs from instances of\DateTimeInterface. - Add
Generator\NameGeneratorInterfaceto support alternate methods of generating bytes for version 3 and version 5 name-based UUID. By default, ramsey/uuid uses theGenerator\DefaultNameGenerator, which uses the standard algorithm this library has used since the beginning. You may choose to use the newGenerator\PeclUuidNameGeneratorto make use of the newuuid_generate_md5()anduuid_generate_sha1()functions in ext-uuid version 1.1.0.
Changed
- Add
fromDateTime()method toUuidFactoryInterface. - Change
UuidInterface::getHex()to return aRamsey\Uuid\Type\Hexadecimalinstance. - Change
UuidInterface::getInteger()to return aRamsey\Uuid\Type\IntegerValueinstance.
Fixed
- Round microseconds to six digits when getting DateTime from v1 UUIDs. This circumvents a needless exception for an otherwise valid time-based UUID.
- Add
-
4.0.0-alpha122 Jan 2020 pre-releaseRelease notes
Open source →Added
- Add
Validator\ValidatorInterfaceandValidator\GenericValidatorto allow flexibility in validating UUIDs/GUIDs.- Add ability to change the default validator used by
UuidthroughFeatureSet::setValidator(). - Add
getValidator()andsetValidator()toUuidFactory.
- Add ability to change the default validator used by
- Add an internal
InvalidArgumentExceptionthat descends from the built-in PHP\InvalidArgumentException. All places that used to throw\InvalidArgumentExceptionnow throwRamsey\Uuid\Exception\InvalidArgumentException. This should not cause any BC breaks, however. - Add an internal
DateTimeExceptionthat descends from the built-in PHP\RuntimeException.Uuid::getDateTime()may throw this exception if\DateTimeImmutablethrows an error or exception. - Add
RandomSourceExceptionthat descends from the built-in PHP\RuntimeException.DefaultTimeGenerator,RandomBytesGenerator, andRandomNodeProvidermay throw this exception ifrandom_bytes()orrandom_int()throw an error or exception. - Add
Fields\FieldsInterfaceandRfc4122\FieldsInterfaceto define field layouts for UUID variants. The implementationsRfc4122\Fields,Guid\Fields, andNonstandard\Fieldsstore the 16-byte, binary string representation of the UUID internally, and these manage conversion of the binary string into the hexadecimal field values. - Add
Rfc4122\UuidInterfaceto specifically represent RFC 4122 variant UUIDs. - Add classes to represent each version of RFC 4122 UUID. When generating new
UUIDs or creating UUIDs from existing strings, bytes, or integers, if the UUID
is an RFC 4122 variant, one of these instances will be returned:
Rfc4122\UuidV1Rfc4122\UuidV2Rfc4122\UuidV3Rfc4122\UuidV4Rfc4122\UuidV5Rfc4122\NilUuid
- Add
Rfc4122\UuidBuilderto build RFC 4122 variant UUIDs. This replaces the existingBuilder\DefaultUuidBuilder, which is now deprecated. - Add ability to generate version 2 (DCE Security) UUIDs, including the static
method
Uuid::uuid2(), which returns anRfc4122\UuidV2instance. - Add classes to represent GUIDs and nonstandard (non-RFC 4122 variant) UUIDs:
Guid\GuidNonstandard\Uuid.
- Introduce a
Builder\FallbackBuilder, used byFeatureSetto help decide whether to return aUuidorNonstandard\Uuidwhen decoding a UUID string or bytes. - Introduce
Type\Hexadecimal,Type\IntegerValue, andType\Timefor improved type-safety when dealing with arbitrary string values. - Introduce
Math\CalculatorInterfacefor representing calculators to perform arithmetic operations on integers. - Depend on brick/math for the
Math\BrickMathCalculator, which is the default calculator used by this library when math cannot be performed in native PHP due to integer size limitations. The calculator is configurable and may be changed, if desired. - Add
Converter\Number\GenericNumberConverterandConverter\Time\GenericTimeConverterwhich will use the calculator provided to convert numbers and time to values for UUIDs. - The
\DateTimeInterfaceinstance returned byUuidInterface::getDateTime()(and nowRfc4122\UuidV1::getDateTime()) now includes microseconds, as specified by the version 1 UUID.
Changed
- Set minimum required PHP version to 7.2.
- Add
__toString()method toUuidInterface. - The
UuidInterface::getDateTime()method now specifies\DateTimeInterfaceas the return value, rather than\DateTime;Uuid::getDateTime()now returns an instance of\DateTimeImmutableinstead of\DateTime. - Add
getFields()method toUuidInterface. - Add
getValidator()method toUuidFactoryInterface. - Add
uuid2()method toUuidFactoryInterface. - Add
convertTime()method toConverter\TimeConverterInterface. - Add
getTime()method toProvider\TimeProviderInterface. - Change
Uuid::getFields()to return an instance ofFields\FieldsInterface. Previously, it returned an array of integer values (on 64-bit systems only). - Change the first required constructor parameter for
Uuidfromarray $fieldstoRfc4122\FieldsInterface $fields. - Introduce
Converter\TimeConverterInterface $timeConverteras fourth required constructor parameter forUuidand second required constructor parameter forBuilder\DefaultUuidBuilder. - Change
UuidInterface::getInteger()to always return astringvalue instead ofmixed. This is a string representation of a 128-bit integer. You may then use a math library of your choice (bcmath, gmp, etc.) to operate on the string integer. - Change the second required parameter of
Builder\UuidBuilderInterface::build()fromarray $fieldstostring $bytes. Rather than accepting an array of hexadecimal strings as UUID fields, thebuild()method now expects a byte string. Generator\DefaultTimeGeneratorno longer adds the variant and version bits to the bytes it returns. These must be applied to the bytes afterwards.Converter/TimeConverterInterface::calculateTime()now returnsType\Hexadecimalinstead ofarray. The value is the full UUID timestamp value (count of 100-nanosecond intervals since the Gregorian calendar epoch) in hexadecimal format.- Change methods in converter interfaces to accept and return string values
instead of
mixed; this simplifies the interface and makes it consistent:NumberConverterInterface::fromHex(string $hex): stringNumberConverterInterface::toHex(string $number): stringTimeConverterInterface::calculateTime(string $seconds, string $microseconds): array
UnsupportedOperationExceptionis now descended from\LogicException. Previously, it descended from\RuntimeException.- When encoding to bytes or decoding from bytes,
OrderedTimeCodecnow checks whether the UUID is an RFC 4122 variant, version 1 UUID. If not, it will throw an exception—InvalidArgumentExceptionwhen usingOrderedTimeCodec::encodeBinary()andUnsupportedOperationExceptionwhen usingOrderedTimeCodec::decodeBytes(). - Out of the box,
Uuid::fromString(),Uuid::fromBytes(), andUuid::fromInteger()will now return either anRfc4122\UuidInterfaceinstance or an instance ofNonstandard\Uuid, depending on whether the input contains an RFC 4122 variant UUID with a valid version identifier. Both implementUuidInterface, so BC breaks should not occur if typehints use the interface. - By default, the following static methods will now return the specific instance
types. This should not cause any BC breaks if typehints target
UuidInterface:Uuid::uuid1returnsRfc4122\UuidV1Uuid::uuid3returnsRfc4122\UuidV3Uuid::uuid4returnsRfc4122\UuidV4Uuid::uuid5returnsRfc4122\UuidV5
Deprecated
The following functionality is deprecated and will be removed in ramsey/uuid 5.0.0.
- The following methods from
UuidInterfaceandUuidare deprecated. Use their counterparts on theRfc4122\FieldsInterfacereturned byUuid::getFields().getClockSeqHiAndReservedHex()getClockSeqLowHex()getClockSequenceHex()getFieldsHex()getNodeHex()getTimeHiAndVersionHex()getTimeLowHex()getTimeMidHex()getTimestampHex()getVariant()getVersion()
- The following methods from
Uuidare deprecated. Use theRfc4122\FieldsInterfaceinstance returned byUuid::getFields()to get theType\Hexadecimalvalue for these fields, and then use the arbitrary-precision arithmetic library of your choice to convert them to string integers.getClockSeqHiAndReserved()getClockSeqLow()getClockSequence()getNode()getTimeHiAndVersion()getTimeLow()getTimeMid()getTimestamp()
getDateTime()onUuidInterfaceandUuidis deprecated. Use this method only on instances ofRfc4122\UuidV1.getUrn()onUuidInterfaceandUuidis deprecated. It is available onRfc4122\UuidInterfaceand classes that implement it.- The following methods are deprecated and have no direct replacements. However,
you may obtain the same information by calling
UuidInterface::getHex()and splitting the return value in half.UuidInterface::getLeastSignificantBitsHex()UuidInterface::getMostSignificantBitsHex()Uuid::getLeastSignificantBitsHex()Uuid::getMostSignificantBitsHex()Uuid::getLeastSignificantBits()Uuid::getMostSignificantBits()
UuidInterface::getNumberConverter()andUuid::getNumberConverter()are deprecated. There is no alternative recommendation, so plan accordingly.Builder\DefaultUuidBuilderis deprecated; transition toRfc4122\UuidBuilder.Converter\Number\BigNumberConverteris deprecated; transition toConverter\Number\GenericNumberConverter.Converter\Time\BigNumberTimeConverteris deprecated; transition toConverter\Time\GenericTimeConverter.Provider\TimeProviderInterface::currentTime()is deprecated; transition to thegetTimestamp()method on the same interface.- The classes for representing and generating degraded UUIDs are deprecated.
These are no longer necessary; this library now behaves the same on 32-bit and
64-bit PHP.
Builder\DegradedUuidBuilderConverter\Number\DegradedNumberConverterConverter\Time\DegradedTimeConverterDegradedUuid
Removed
- Remove the following bytes generators and recommend
Generator\RandomBytesGeneratoras a suitable replacement:Generator\MtRandGeneratorGenerator\OpenSslGeneratorGenerator\SodiumRandomGenerator
- Remove
Exception\UnsatisfiedDependencyException. This library no longer throws this exception.
- Add
-
3.9.719 Dec 2022 -
3.9.625 Sep 2021 -
3.9.524 Sep 2021Release notes
Open source →Fixed
- Indicate support for PHP 8.1, using
~8.1.0to prevent installations on 8.2 until the library is ready.
- Indicate support for PHP 8.1, using
-
3.9.406 Aug 2021Release notes
Open source →Fixed
- Allow installation of paragonie/random_compat v9.99.100 (for PHP 8 compatibility).
-
3.9.321 Feb 2020Release notes
Open source →Fixed
-
For v1 UUIDs, round down for timestamps so that microseconds do not bump the timestamp to the next second.
As an example, consider the case of timestamp
1with600000microseconds (1.600000). This is the first second after midnight on January 1, 1970, UTC. Previous versions of this library had a bug that would round this to2, so the rendered time was1970-01-01 00:00:02. This was incorrect. Despite having600000microseconds, the time should not round up to the next second. Rather, the time should be1970-01-01 00:00:01.600000. Since this version of ramsey/uuid does not support microseconds, the microseconds are dropped, and the time is1970-01-01 00:00:01. No rounding should occur.
-
-
3.9.217 Dec 2019Release notes
Open source →Fixed
- Check whether files returned by
/sys/class/net/*/addressare readable before attempting to read them. This avoids a PHP warning that was being emitted on hosts that do not grant permission to read these files.
- Check whether files returned by
-
3.9.101 Dec 2019Release notes
Open source →Fixed
- Fix
RandomNodeProviderbehavior on 32-bit systems. TheRandomNodeProviderwas converting a 6-byte string to a decimal number, which is a 48-bit, unsigned integer. This caused problems on 32-bit systems and has now been resolved.
- Fix
-
3.9.030 Nov 2019Release notes
Open source →Added
- Add function API as convenience. The functions are available in the
Ramsey\Uuidnamespace.v1(int|string|null $node = null, int|null $clockSeq = null): stringv3(string|UuidInterface $ns, string $name): stringv4(): stringv5(string|UuidInterface $ns, string $name): string
Changed
- Use paragonie/random-lib instead of ircmaxell/random-lib. This is a non-breaking change.
- Use a high-strength generator by default, when using
RandomLibAdapter. This is a non-breaking change.
Deprecated
These will be removed in ramsey/uuid version 4.0.0:
MtRandGenerator,OpenSslGenerator, andSodiumRandomGeneratorare deprecated in favor of using the defaultRandomBytesGenerator.
Fixed
- Set
ext-jsonas a required dependency incomposer.json. - Use
PHP_OSinstead ofphp_uname()when determining the system OS, for cases whenphp_uname()is disabled for security reasons.
- Add function API as convenience. The functions are available in the
-
3.8.019 Jul 2018Release notes
Open source →Added
- Support discovery of MAC addresses on FreeBSD systems
- Use a polyfill to provide PHP ctype functions when running on systems where the ctype functions are not part of the PHP build
- Disallow a trailing newline character when validating UUIDs
- Annotate thrown exceptions for improved IDE hinting
-
3.7.320 Jan 2018Release notes
Open source →Fixed
- Gracefully handle cases where
glob()returns false when searching/sys/class/net/*/addressfiles on Linux - Fix off-by-one error in
DefaultTimeGenerator
Security
- Switch to
random_int()frommt_rand()for better random numbers
- Gracefully handle cases where
-
3.7.213 Jan 2018Release notes
Open source →Fixed
- Check sysfs on Linux to determine the node identifier; this provides a reliable way to identify the node on Docker images, etc.
-
3.7.122 Sep 2017Release notes
Open source →Fixed
- Set the multicast bit for random nodes, according to RFC 4122, §4.5
Security
- Use
random_bytes()when generating random nodes
-
3.7.004 Aug 2017Release notes
Open source →Added
- Add the following UUID version constants:
Uuid::UUID_TYPE_TIMEUuid::UUID_TYPE_IDENTIFIERUuid::UUID_TYPE_HASH_MD5Uuid::UUID_TYPE_RANDOMUuid::UUID_TYPE_HASH_SHA1
- Add the following UUID version constants:
-
3.6.126 Mar 2017Release notes
Open source →Fixed
- Optimize UUID string decoding by using
str_pad()instead ofsprintf()
- Optimize UUID string decoding by using
-
3.6.018 Mar 2017Release notes
Open source →Added
- Add
InvalidUuidStringException, which is thrown when attempting to decode an invalid string UUID; this does not introduce any BC issues, since the new exception inherits from the previously usedInvalidArgumentException
Fixed
- Improve memory usage when generating large quantities of UUIDs (use
str_pad()anddechex()instead ofsprintf())
- Add
-
3.5.222 Nov 2016 -
3.5.102 Oct 2016Release notes
Open source →Fixed
- Fix issue where the same UUIDs were not being treated as equal when using mixed cases
-
3.5.002 Aug 2016Release notes
Open source →Added
- Add
OrderedTimeCodecto store UUID in an optimized way for InnoDB
Fixed
- Fix invalid node generation in
RandomNodeProvider - Avoid multiple unnecessary system calls by caching failed attempt to retrieve system node
- Add
-
3.4.124 Apr 2016 -
3.4.024 Apr 2016Release notes
Open source →Added
- Add
TimestampFirstCombCodecandTimestampLastCombCodeccodecs to provide the ability to generate [COMB sequential UUIDs] with the timestamp encoded as either the first 48 bits or the last 48 bits - Improve logic of
CombGeneratorfor COMB sequential UUIDs
- Add
-
3.3.022 Mar 2016Release notes
Open source →Security
- Drop the use of OpenSSL as a fallback and use [paragonie/random_compat] to
support
RandomBytesGeneratorin versions of PHP earlier than 7.0; this addresses and fixes the [collision issue]
- Drop the use of OpenSSL as a fallback and use [paragonie/random_compat] to
support
-
3.2.017 Feb 2016Release notes
Open source →Added
- Add
SodiumRandomGeneratorto allow use of the [PECL libsodium extension] as a random bytes generator when creating UUIDs
- Add