PHPackages                             bentools/doctrine-ulid - 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. bentools/doctrine-ulid

Abandoned → [symfony/uid](/?search=symfony%2Fuid)ArchivedLibrary[Database &amp; ORM](/categories/database)

bentools/doctrine-ulid
======================

ULID (Universally Unique Lexicographically Sortable Identifier) support for Doctrine IDs

1.2(5y ago)45.1k11MITPHPPHP &gt;=7.3

Since Jan 15Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/bpolaszek/doctrine-ulid)[ Packagist](https://packagist.org/packages/bentools/doctrine-ulid)[ RSS](/packages/bentools-doctrine-ulid/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (6)Versions (6)Used By (1)

[![Latest Stable Version](https://camo.githubusercontent.com/f3a5d3112052de2b53c920a181cc02d7af2776bd5ffdaf3bf6fb2500c7e413ff/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f646f637472696e652d756c69642f762f737461626c65)](https://packagist.org/packages/bentools/doctrine-ulid)[![License](https://camo.githubusercontent.com/45e80534bee0e3bbd10fd51117c972646706644a41ef5cd8a7940282d2a4b439/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f646f637472696e652d756c69642f6c6963656e7365)](https://packagist.org/packages/bentools/doctrine-ulid)[![Build Status](https://github.com/bpolaszek/doctrine-ulid/workflows/CI%20Workflow/badge.svg)](https://github.com/bpolaszek/doctrine-ulid/workflows/CI%20Workflow/badge.svg)[![Coverage](https://camo.githubusercontent.com/0a8021395c63bae132f390769541a6cb2b4bfff10266f677d23ed50739915a35/68747470733a2f2f636f6465636f762e696f2f67682f62706f6c61737a656b2f646f637472696e652d756c69642f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d4c5947594e4456384432)](https://codecov.io/gh/bpolaszek/doctrine-ulid)[![Quality Score](https://camo.githubusercontent.com/6e06ddd929d2bf5cef2dbe9ef1f034c632ff0c66f7b9a9b24e50060215e35189/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f62706f6c61737a656b2f646f637472696e652d756c69642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/bpolaszek/doctrine-ulid)[![Total Downloads](https://camo.githubusercontent.com/ecc5c71849c7ee515f9d40c6ac7a642e3a1cf7a1ecc5cb78faa9dc99279cf7ef/68747470733a2f2f706f7365722e707567782e6f72672f62656e746f6f6c732f646f637472696e652d756c69642f646f776e6c6f616473)](https://packagist.org/packages/bentools/doctrine-ulid)

Doctrine ULID generator
=======================

[](#doctrine-ulid-generator)

This small library adds support for [ULID](https://github.com/ulid/spec) in Doctrine.

ULIDs act like UUIDs that can be lexicographically sorted. ULIDs also have a smaller footprint (26 ANSI characters vs. 36 for UUIDs);

This package integrates [robinvdvleuten/ulid](https://github.com/robinvdvleuten/php-ulid) as a `CustomIdGenerator`.

Important

This repository is no longer maintained. Please use `symfony/uid` instead.

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

[](#installation)

```
composer require bentools/doctrine-ulid
```

Usage
-----

[](#usage)

Use the provided class as a custom ID generator:

```
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity()
 */
class Foo
{

    /**
     * @var string
     *
     * @ORM\Id()
     * @ORM\GeneratedValue(strategy="CUSTOM")
     * @ORM\CustomIdGenerator(class="\BenTools\ULIDGenerator")
     * @ORM\Column(type="string", length=26)
     */
    private $id;

    // ...

}
```

Or use the following trait:

```
use Doctrine\ORM\Mapping as ORM;
use BenTools\GeneratedULIDTrait;

/**
 * @ORM\Entity()
 */
class Foo
{

    use GeneratedULIDTrait;

    // ...

}
```

If you want to set ULIDs by yourself (this way, they can be generated on the client side), use the `EditableULIDTrait` which will expose a `setId()` method:

```
use Doctrine\ORM\Mapping as ORM;
use BenTools\EditableULIDTrait;

/**
 * @ORM\Entity()
 * @ORM\HasLifecycleCallbacks()
 */
class Foo
{

    use EditableULIDTrait;

    // ...

}
```

- If `setId()` is not called, an ULID will be automatically generated on persist.
- Don't forget to add a `@HasLifecycleCallbacks()` annotation on top of your entity for this behavior to work properly.

Tests
-----

[](#tests)

```
./vendor/bin/phpunit
```

License
-------

[](#license)

MIT.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance43

Moderate activity, may be stable

Popularity22

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~246 days

Total

4

Last Release

1936d ago

PHP version history (2 changes)1.1PHP &gt;=7.1

1.2PHP &gt;=7.3

### Community

Maintainers

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

---

Top Contributors

[![bpolaszek](https://avatars.githubusercontent.com/u/5569077?v=4)](https://github.com/bpolaszek "bpolaszek (9 commits)")

---

Tags

ormdoctrineuuidulid

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/bentools-doctrine-ulid/health.svg)

```
[![Health](https://phpackages.com/badges/bentools-doctrine-ulid/health.svg)](https://phpackages.com/packages/bentools-doctrine-ulid)
```

###  Alternatives

[gedmo/doctrine-extensions

Doctrine behavioral extensions

4.1k118.8M366](/packages/gedmo-doctrine-extensions)[beberlei/doctrineextensions

A set of extensions to Doctrine 2 that add support for additional query functions available in MySQL, Oracle, PostgreSQL and SQLite.

2.1k75.1M146](/packages/beberlei-doctrineextensions)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[knplabs/doctrine-behaviors

Doctrine Behavior Traits

92212.7M64](/packages/knplabs-doctrine-behaviors)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M36](/packages/scienta-doctrine-json-functions)[sonata-project/doctrine-orm-admin-bundle

Integrate Doctrine ORM into the SonataAdminBundle

46117.7M155](/packages/sonata-project-doctrine-orm-admin-bundle)

PHPackages © 2026

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