PHPackages                             tito10047/type-safe-id-bundle - 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. tito10047/type-safe-id-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tito10047/type-safe-id-bundle
=============================

Type safe UUID or Ulid bundle

1.2.0(1mo ago)75MITPHPPHP &gt;=8.2CI passing

Since Mar 15Pushed 1mo agoCompare

[ Source](https://github.com/tito10047/type-safe-id-bundle)[ Packagist](https://packagist.org/packages/tito10047/type-safe-id-bundle)[ RSS](/packages/tito10047-type-safe-id-bundle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (6)Used By (0)

🛡️ Type-Safe Id Bundle
======================

[](#️-type-safe-id-bundle)

[![Build Status](https://github.com/tito10047/type-safe-id-bundle/actions/workflows/tests.yml/badge.svg)](https://github.com/tito10047/type-safe-id-bundle/actions)[![Latest Stable Version](https://camo.githubusercontent.com/0c5ebcf6567b56e0c9313a8a546cee79321ac85c55296b5c6bd20960b17047af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7469746f31303034372f747970652d736166652d69642d62756e646c652e737667)](https://packagist.org/packages/tito10047/type-safe-id-bundle)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE.md)[![PHP Version](https://camo.githubusercontent.com/5814289f8aa8cd4671b9582f7c4172d2d1af7fccd603b5d707234f0e02ad69d8/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344253230382e322d3838393262662e737667)](https://php.net)[![Symfony Version](https://camo.githubusercontent.com/53416821fd3b1fa333526703e925b1e354a9fe61bd2978b45e0647bb9a72588b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53796d666f6e792d253345253344253230372e342d626c61636b3f6c6f676f3d73796d666f6e79)](https://symfony.com/)[![Coverage Status](https://camo.githubusercontent.com/28ffbdc13763649ed1a7898be23794a6df1baba8626e9e530938255369337460/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7469746f31303034372f747970652d736166652d69642d62756e646c652f62616467652e737667)](https://coveralls.io/github/tito10047/type-safe-id-bundle)

Introduction
------------

[](#introduction)

> ⚠️ **WARNING**: This is an experimental package and may not be suitable for production use. Use at your own risk.

### 🏗️ DDD Ready

[](#️-ddd-ready)

This bundle is designed with **Domain-Driven Design (DDD)** in mind. It allows you to separate your domain entities, their unique type-safe identifiers, and repositories into different namespaces or directories through configuration.

When working with Symfony and Doctrine, using UUIDs as entity identifiers is a common approach. Traditionally, IDs are stored as simple integers or as raw Uuid objects. However, this can lead to type confusion, especially when working with Symfony Messenger or repository methods. A more robust and type-safe approach is to use dedicated ID classes.

📊 **[Performance Benchmarks](BENCHMARK_FINDINGS.md)** - See detailed performance analysis comparing TypeSafeId with classic Doctrine approach.

---

This package provides `bin/console make:entity:type` to generate entities with Type-safe identifiers. This is implementation of [this article](https://sensiolabs.com/blog/2025/type-safe-identifiers-symfony-doctrine)

It generates something like this:

```
$ bin/console make:entity:type Foo --with-ulid
```

```
#[ORM\Entity(repositoryClass: FooRepository::class)]
class Foo
{
    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
    #[ORM\CustomIdGenerator(class: 'doctrine.id_generator.universal')]
    #[ORM\Column(type: FooIdType::class, unique: true)]
    private ?FooId $id = null;

    public function getId(): FooId
    {
        return $this->id;
    }
}
```

```
class FooRepository extends ServiceEntityRepository
{
    //...
    public function get(FooId $id): ?Foo    {
        return $this->find($id->toString());
    }
    //...
}
```

### Configuration (DDD Support)

[](#configuration-ddd-support)

You can customize where your files are generated by specifying their namespaces. This is especially useful for DDD structures.

Create a configuration file `config/packages/type_safe_id.yaml`:

```
type_safe_id:
    # Default values:
    entity_namespace: 'App\Entity'
    type_id_namespace: 'App\EntityId'
    repository_namespace: 'App\Repository'
```

If you use a different structure (e.g. `src\Domain\User`), the maker command will respect these namespaces.

### Usage

[](#usage)

```
// IDs are automatically generated by Doctrine when persisting entities
$foo = new Foo();
$poo = new Poo();
$this->em->persist($foo);
$this->em->persist($poo);
$this->em->flush();

$serializedFooId = serialize($foo->getId());
$serializedPooId = serialize($poo->getId());

// This works - correct type
$foo = $this->fooRepository->get(unserialize($serializedFooId));

// This throws Exception: App\Repository\FooRepository::get():
// Argument #1 ($id) must be of type App\EntityId\FooId, App\EntityId\PooId given
$foo = $this->fooRepository->get(unserialize($serializedPooId));
```

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

[](#installation)

Make sure Composer is installed globally, as explained in the [installation chapter](https://getcomposer.org/doc/00-intro.md)of the Composer documentation.

### Applications that use Symfony Flex

[](#applications-that-use-symfony-flex)

Open a command console, enter your project directory and execute:

```
$ composer require tito10047/type-safe-id-bundle
```

### Applications that don't use Symfony Flex

[](#applications-that-dont-use-symfony-flex)

#### Step 1: Download the Bundle

[](#step-1-download-the-bundle)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
$ composer require tito10047/type-safe-id-bundle
```

#### Step 2: Enable the Bundle

[](#step-2-enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in the `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    Tito10047\TypeSafeIdBundle\TypeSafeIdBundle::class => ['all' => true],
];
```

###  Health Score

43

—

FairBetter than 90% of packages

Maintenance95

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

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 ~0 days

Total

4

Last Release

53d ago

Major Versions

1.1.0 → v2.x-dev2026-03-17

### Community

Maintainers

![](https://www.gravatar.com/avatar/3d6d558226302620ec462f64672e9dc81609227626923a808005641e76e8c38f?d=identicon)[tito10047](/maintainers/tito10047)

---

Top Contributors

[![tito10047](https://avatars.githubusercontent.com/u/11459248?v=4)](https://github.com/tito10047 "tito10047 (29 commits)")

### Embed Badge

![Health badge](/badges/tito10047-type-safe-id-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tito10047-type-safe-id-bundle/health.svg)](https://phpackages.com/packages/tito10047-type-safe-id-bundle)
```

###  Alternatives

[winzou/state-machine-bundle

Bundle for the very lightweight yet powerful PHP state machine

34010.4M15](/packages/winzou-state-machine-bundle)[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[sylius/taxonomy-bundle

Flexible categorization system for Symfony.

26388.2k7](/packages/sylius-taxonomy-bundle)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[sylius/addressing-bundle

Addressing and zone management for Symfony applications.

33221.4k3](/packages/sylius-addressing-bundle)[sylius/inventory-bundle

Flexible inventory management for Symfony applications.

19176.7k4](/packages/sylius-inventory-bundle)

PHPackages © 2026

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