PHPackages                             cycle/entity-behavior-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. [Database &amp; ORM](/categories/database)
4. /
5. cycle/entity-behavior-identifier

ActiveLibrary[Database &amp; ORM](/categories/database)

cycle/entity-behavior-identifier
================================

Provides the ability to use ramsey/identifier as various Cycle ORM entity column types

0.1.0(2mo ago)310[2 issues](https://github.com/cycle/entity-behavior-identifier/issues)MITPHPPHP &gt;=8.2CI passing

Since Apr 30Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/cycle/entity-behavior-identifier)[ Packagist](https://packagist.org/packages/cycle/entity-behavior-identifier)[ Docs](https://cycle-orm.dev)[ GitHub Sponsors](https://github.com/sponsors/cycle)[ RSS](/packages/cycle-entity-behavior-identifier/feed)WikiDiscussions 1.x Synced today

READMEChangelog (1)Dependencies (16)Versions (3)Used By (0)

Cycle ORM Entity Behavior Identifier
====================================

[](#cycle-orm-entity-behavior-identifier)

[![Latest Stable Version](https://camo.githubusercontent.com/c0fda1938ad3e29533c0866ab8f42ebd2e29acaca151787dab2b3c6db4af6ea6/68747470733a2f2f706f7365722e707567782e6f72672f6379636c652f656e746974792d6265686176696f722d6964656e7469666965722f76657273696f6e)](https://packagist.org/packages/cycle/entity-behavior-identifier)[![Build Status](https://github.com/cycle/entity-behavior-identifier/workflows/build/badge.svg)](https://github.com/cycle/entity-behavior-identifier/actions)[![Codecov](https://camo.githubusercontent.com/0d5691816c38655cb5473a7504817b4c820c16e263071be80add755523062412/68747470733a2f2f636f6465636f762e696f2f67682f6379636c652f656e746974792d6265686176696f722d6964656e7469666965722f67726170682f62616467652e737667)](https://codecov.io/gh/cycle/entity-behavior)[![](https://camo.githubusercontent.com/4442b73a11753b80fdd7b442ddbfaf8383902c8b9ffa66ed1718e8c62e102f2e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646973636f72642d636861742d6d6167656e74612e737667)](https://discord.gg/TFeEmCs)

The package provides the ability to use `ramsey/identifier` as various Cycle ORM entity column types.

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

[](#installation)

> **Note:** Due to a dependency on `ramsey/identifier` this package requires PHP `8.2` or newer.

Install this package as a dependency using Composer.

```
composer require cycle/entity-behavior-identifier
```

Usage
-----

[](#usage)

The package provides various types of identifiers, for generating unique values or as alternatives to auto-increment IDs, helping ensure uniqueness and flexibility across an application.

> \*\*Note: \*\* Most identifiers encode metadata such as node ID and epoch offset. These values are typically derived from the platform or system rather than defined within an entity. Each applicable listener class provides a `setDefaults` method to allow these values to be set at an appropriate time within your application.

For example:

```
\Cycle\ORM\Entity\Behavior\Identifier\Listener\SnowflakeGeneric::setDefaults(0, 1_446_940_800_000);
\Cycle\ORM\Entity\Behavior\Identifier\Listener\Uuid1::setDefaults('00000fffffff', 0xffff);
```

### Snowflake Examples

[](#snowflake-examples)

**Snowflake (Generic):** A flexible Snowflake implementation that generates globally unique, time-ordered 64-bit IDs without adhering to any specific platform’s conventions, suitable for general distributed systems.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Snowflake;

#[Entity]
#[Identifier\SnowflakeGeneric(field: 'id')]
class User
{
    #[Column(type: 'id', primary: true)]
    public Snowflake $id;
}
```

**Snowflake (Discord):** Implements Discord’s Snowflake format, generating 64-bit IDs that encode a timestamp, worker ID, and sequence number. Useful when interoperating with Discord’s API or matching its ID structure.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Snowflake;

#[Entity]
#[Identifier\SnowflakeDiscord(field: 'id')]
class User
{
    #[Column(type: 'id', primary: true)]
    public Snowflake $id;
}
```

**Snowflake (Instagram):** Follows Instagram’s Snowflake structure to produce unique, sortable 64-bit IDs suitable for applications that need compatibility with Instagram-style ID sequences.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Snowflake;

#[Entity]
#[Identifier\SnowflakeInstagram(field: 'id')]
class User
{
    #[Column(type: 'id', primary: true)]
    public Snowflake $id;
}
```

**Snowflake (Mastodon):** Generates IDs compatible with Mastodon’s distributed Snowflake system, encoding time and node information to ensure uniqueness across instances.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Snowflake;

#[Entity]
#[Identifier\SnowflakeMastodon(field: 'id')]
class User
{
    #[Column(type: 'id', primary: true)]
    public Snowflake $id;
}
```

**Snowflake (Twitter):** Produces 64-bit IDs in the format used by Twitter, encoding timestamp, machine ID, and sequence number for globally unique, time-sortable identifiers. Ideal for high-throughput distributed systems.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Snowflake;

#[Entity]
#[Identifier\SnowflakeTwitter(field: 'id')]
class User
{
    #[Column(type: 'id', primary: true)]
    public Snowflake $id;
}
```

### ULID Examples

[](#ulid-examples)

**ULID (Universally Unique Lexicographically Sortable Identifier):** A 128-bit identifier designed for high uniqueness and lexicographical sortability. It combines a timestamp component with random data, allowing for ordered IDs that can be generated rapidly and are human-readable, making it ideal for databases and distributed systems.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Ulid;

#[Entity]
#[Identifier\Ulid(field: 'id')]
class User
{
    #[Column(type: 'ulid', primary: true)]
    private Ulid $id;
}
```

### UUID Examples

[](#uuid-examples)

**UUID Version 1 (Time-based):** Generated using the current timestamp and the MAC address of the computer, ensuring unique identification based on time and hardware.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Uuid;

#[Entity]
#[Identifier\Uuid1(field: 'id')]
class User
{
    #[Column(type: 'uuid', primary: true)]
    private Uuid $id;
}
```

**UUID Version 2 (DCE Security):** Similar to version 1 but includes a local identifier such as a user ID or group ID, primarily used in DCE security contexts.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Uuid;

#[Entity]
#[Identifier\Uuid2(field: 'id')]
class User
{
    #[Column(type: 'uuid', primary: true)]
    private Uuid $id;
}
```

**UUID Version 3 (Name-based, MD5):** Created by hashing a namespace identifier and name using MD5, resulting in a deterministic UUID based on input data.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Uuid;

#[Entity]
#[Identifier\Uuid3(
    field: 'id',
    namespace: '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
    name: 'example.com',
)]
class User
{
    #[Column(type: 'uuid', primary: true)]
    private Uuid $id;
}
```

**UUID Version 4 (Random):** Generated entirely from random or pseudo-random numbers, offering high unpredictability and uniqueness.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Uuid;

#[Entity]
#[Identifier\Uuid4(field: 'id')]
class User
{
    #[Column(type: 'uuid', primary: true)]
    private Uuid $id;
}
```

**UUID Version 5 (Name-based, SHA-1):** Similar to version 3 but uses SHA-1 hashing, providing a different deterministic UUID based on namespace and name.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Uuid;

#[Entity]
#[Identifier\Uuid5(
    field: 'id',
    namespace: '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
    name: 'example.com',
)]
class User
{
    #[Column(type: 'uuid', primary: true)]
    private Uuid $id;
}
```

**UUID Version 6 (Draft/Upcoming):** An experimental or proposed version focused on improving time-based UUIDs with more sortable properties (not yet widely adopted).

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Uuid;

#[Entity]
#[Identifier\Uuid6(field: 'id')]
class User
{
    #[Column(type: 'uuid', primary: true)]
    private Uuid $id;
}
```

**UUID Version 7 (Draft/Upcoming):** A newer proposal designed to incorporate sortable features based on Unix timestamp, enhancing performance in database indexing.

```
use Cycle\Annotated\Annotation\Column;
use Cycle\Annotated\Annotation\Entity;
use Cycle\ORM\Entity\Behavior\Identifier;
use Ramsey\Identifier\Uuid;

#[Entity]
#[Identifier\Uuid7(field: 'id')]
class User
{
    #[Column(type: 'uuid', primary: true)]
    private Uuid $id;
}
```

Read more about identifier generation in [Entity Behaviors: Identifiers](https://cycle-orm.dev/docs/entity-behaviors/identifiers.md).

License:
--------

[](#license)

The MIT License (MIT). Please see [`LICENSE`](./LICENSE) for more information. Maintained by [Spiral Scout](https://spiralscout.com).

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance74

Regular maintenance activity

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 85.1% 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

Every ~0 days

Total

2

Last Release

64d ago

Major Versions

0.1.0 → 1.x-dev2026-04-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/796136?v=4)[Anton Tsitou](/maintainers/wolfy-j)[@wolfy-j](https://github.com/wolfy-j)

---

Top Contributors

[![puzzledpolymath](https://avatars.githubusercontent.com/u/162779269?v=4)](https://github.com/puzzledpolymath "puzzledpolymath (63 commits)")[![roxblnfk](https://avatars.githubusercontent.com/u/4152481?v=4)](https://github.com/roxblnfk "roxblnfk (11 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cycle-entity-behavior-identifier/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3535.8k3](/packages/wayofdev-laravel-cycle-orm-adapter)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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