PHPackages                             ramsey/identifier - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ramsey/identifier

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ramsey/identifier
=================

A PHP library for generating and working with identifiers, including UUIDs, ULIDs, and Snowflakes

0.1.0(11mo ago)603.0k↓42.3%7[3 PRs](https://github.com/ramsey/identifier/pulls)1LGPL-3.0-or-laterPHPCI passing

Since Jun 19Pushed 6mo ago3 watchersCompare

[ Source](https://github.com/ramsey/identifier)[ Packagist](https://packagist.org/packages/ramsey/identifier)[ RSS](/packages/ramsey-identifier/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (23)Versions (4)Used By (1)

ramsey/identifier
=================

[](#ramseyidentifier)

 **A PHP library for generating and working with identifiers**

 [![Source Code](https://camo.githubusercontent.com/8a247349caf8df26c632544205ecedf252579262c2b45d7a18746c63f074d3c7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f736f757263652d72616d7365792f6964656e7469666965722d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/ramsey/identifier) [![Download Package](https://camo.githubusercontent.com/6e2286696b8ab27220ef0cc6136116a3627869382f047b58c8d79a626f09a7fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f72616d7365792f6964656e7469666965722e7376673f7374796c653d666c61742d737175617265266c6162656c3d72656c65617365)](https://packagist.org/packages/ramsey/identifier) [![PHP Programming Language](https://camo.githubusercontent.com/cade22a8834f5f2ea01eda608d511ecf35b4f9673e85fdb78be6764808155a30/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f72616d7365792f6964656e7469666965722f7068702d36346269743f7374796c653d666c61742d73717561726526636f6c6f72423d253233383839324246)](https://php.net) [![Read License](https://camo.githubusercontent.com/7cc0832451a0f431d212d7e177e2abbd7d7fe5e2c94e4f76d830417d7e678bfb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f72616d7365792f6964656e7469666965723f7374796c653d666c61742d73717561726526636f6c6f72423d6461726b6379616e)](https://github.com/ramsey/identifier/blob/main/COPYING.LESSER) [![Build Status](https://camo.githubusercontent.com/af09437b332636b5aac7e02cba25f243477ad95e7cd535adb8d3aadd71fa19a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f72616d7365792f6964656e7469666965722f636f6e74696e756f75732d696e746567726174696f6e2e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6f676f3d676974687562)](https://github.com/ramsey/identifier/actions/workflows/continuous-integration.yml) [![Codecov Code Coverage](https://camo.githubusercontent.com/69539a86ca0d189febd6c2de53a75448cb3f275e00d039bf55b71573de4b46bf/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f72616d7365792f6964656e7469666965723f6c6162656c3d636f6465636f76266c6f676f3d636f6465636f76267374796c653d666c61742d737175617265)](https://codecov.io/gh/ramsey/identifier)

About
-----

[](#about)

ramsey/identifier is a PHP library designed for generating, parsing, and working with a variety of unique identifiers. It provides an object-oriented interface for several industry-standard identifier formats—including UUIDs, ULIDs, and Snowflake IDs. This library emphasizes standards-compliance, interoperability, and developer ergonomics, making it easy to create and manipulate identifiers in modern PHP applications.

This project adheres to a [code of conduct](CODE_OF_CONDUCT.md). By participating in this project and its community, you are expected to uphold this code.

Installation
------------

[](#installation)

Install this package as a dependency using [Composer](https://getcomposer.org).

```
composer require ramsey/identifier
```

Usage
-----

[](#usage)

ramsey/identifier provides ways to generate industry-standard identifiers, such as UUIDs, ULIDs, and Snowflake IDs. You can do this using the provided factory classes:

```
use Ramsey\Identifier\Snowflake\GenericSnowflakeFactory;
use Ramsey\Identifier\Snowflake\Epoch;
use Ramsey\Identifier\Ulid\UlidFactory;
use Ramsey\Identifier\Uuid\UuidFactory;

// Create a UUID.
$uuid = (new UuidFactory())->create();

// Create a ULID.
$ulid = (new UlidFactory())->create();

// Create a Snowflake.
$snowflake = (new GenericSnowflakeFactory(1, Epoch::Unix))->create();
```

With `UuidFactory`, you may create UUIDs of different versions:

```
use Ramsey\Identifier\Uuid\NamespaceId;

$factory = new UuidFactory();

// Create random UUIDs (version 4).
$uuidV4 = $factory->v4();

// Create named-based UUIDs using SHA-1 hashing (version 5).
$uuidV5 = $factory->v5(NamespaceId::Url, 'https://example.com/post/1234');

// Create Unix Epoch time-based UUIDs (version 7).
$uuidV7 = $factory->v7();
```

You may also parse existing identifiers:

```
// Parse a UUID.
$uuid = (new UuidFactory())->createFromString('01977bea-d1c0-7154-87bb-6550974155c2');

// Parse a ULID.
$ulid = (new UlidFactory())->createFromString('01JXXYNME0E5A8FEV5A2BM2NE2');

// Parse a Snowflake ID.
$snowflake = (new GenericSnowflakeFactory(1, Epoch::Unix))->createFromInteger(7340580095540599922);
```

Each of these identifiers happen to contain the same timestamp, which we can retrieve:

```
echo $uuid->getDateTime()->format('Y-m-d H:i:s.v P') . "\n";
echo $ulid->getDateTime()->format('Y-m-d H:i:s.v P') . "\n";
echo $snowflake->getDateTime()->format('Y-m-d H:i:s.v P') . "\n";
```

This will print:

```
2025-06-17 03:24:36.160 +00:00
2025-06-17 03:24:36.160 +00:00
2025-06-17 03:24:36.160 +00:00

```

The UUID and ULID shown above have the same underlying byte values. Every version 7 UUID can also be expressed as a ULID, but not every ULID can be converted into a version 7 UUID. Similarly, Snowflake identifiers and ULIDs both encode a timestamp and randomness, but their formats are not directly interchangeable with UUIDs or each other.

```
if ($uuid->equals($ulid)) {
    echo "They are equal!\n";
}

if ($uuid->equals($snowflake)) {
    echo "The timestamp is the same, but they aren't equal.\n"
}
```

Contributing
------------

[](#contributing)

Contributions are welcome! To contribute, please familiarize yourself with [CONTRIBUTING.md](CONTRIBUTING.md).

Coordinated Disclosure
----------------------

[](#coordinated-disclosure)

Keeping user information safe and secure is a top priority, and we welcome the contribution of external security researchers. If you believe you've found a security issue in software that is maintained in this repository, please read [SECURITY.md](SECURITY.md) for instructions on submitting a vulnerability report.

Copyright and License
---------------------

[](#copyright-and-license)

ramsey/identifier is copyright © [Ben Ramsey](https://ramsey.dev) and [Contributors](https://github.com/ramsey/identifier/graphs/contributors)and licensed for use under the terms of the GNU Lesser General Public License (LGPL-3.0-or-later) as published by the Free Software Foundation. Please see [COPYING.LESSER](COPYING.LESSER), [COPYING](COPYING), and [NOTICE](NOTICE) for more information.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance60

Regular maintenance activity

Popularity36

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity28

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

334d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f514481fa9cfdfd5dbcaccb3e5b480f18ea05ebf331cddf9b1c5a2a96a78fef5?d=identicon)[ramsey](/maintainers/ramsey)

---

Top Contributors

[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (208 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (20 commits)")[![mxr576](https://avatars.githubusercontent.com/u/1755573?v=4)](https://github.com/mxr576 "mxr576 (1 commits)")

---

Tags

guidididentifierphpsnowflakeuiduliduuiduuididentifierguidUIDulididsnowflake

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ramsey-identifier/health.svg)

```
[![Health](https://phpackages.com/badges/ramsey-identifier/health.svg)](https://phpackages.com/packages/ramsey-identifier)
```

###  Alternatives

[ramsey/uuid

A PHP library for generating and working with universally unique identifiers (UUIDs).

12.6k700.2M3.3k](/packages/ramsey-uuid)[identifier/identifier

Common Interfaces and Factories for Identifiers

3226.2k1](/packages/identifier-identifier)[symfony/uid

Provides an object-oriented API to generate and represent UIDs

610280.0M754](/packages/symfony-uid)[pascaldevink/shortuuid

PHP 7.4+ library that generates concise, unambiguous, URL-safe UUIDs

5951.8M15](/packages/pascaldevink-shortuuid)[keiko/uuid-shortener

A simple shortener library for RFC 4122 compatible UUIDs. Change your 36 chars long UUID into it's shorter equivalent.

150215.4k2](/packages/keiko-uuid-shortener)[oittaa/uuid

A small PHP class for generating RFC 9562 universally unique identifiers (UUID) from version 3 to version 8.

50302.7k5](/packages/oittaa-uuid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
