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

ActiveSymfony-bundle[Database &amp; ORM](/categories/database)

letkode/entity-traits-bundle
============================

Doctrine entity traits, value objects, DTOs and DQL utilities for Symfony applications

1.0.1(today)00MITPHPPHP ^8.4

Since Jun 19Pushed todayCompare

[ Source](https://github.com/letkode/entity-traits-bundle)[ Packagist](https://packagist.org/packages/letkode/entity-traits-bundle)[ RSS](/packages/letkode-entity-traits-bundle/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (9)Versions (3)Used By (0)

letkode/entity-traits-bundle
============================

[](#letkodeentity-traits-bundle)

Doctrine entity traits, repository traits, value objects, DTOs and DQL utilities for Symfony applications.

---

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

[](#installation)

```
composer require letkode/entity-traits-bundle
```

Symfony Flex will register the bundle automatically. If not using Flex, add it manually:

```
// config/bundles.php
return [
    Letkode\EntityTraitsBundle\LetkodeEntityTraitsBundle::class => ['all' => true],
];
```

The bundle automatically registers the `TRANSLATE_FIELD_VALUE` Doctrine DQL function via `PrependExtensionInterface`.

---

Entity Traits
-------------

[](#entity-traits)

### `UuidTrait`

[](#uuidtrait)

Adds a `uuid` column (UUIDv7) with a PostgreSQL `uuidv7()` default. The `UuidGeneratorSubscriber` ensures PHP-side generation before persist so Gedmo Loggable captures the value.

```
use Letkode\EntityTraitsBundle\Trait\Entity\UuidTrait;

#[ORM\Entity]
class Product
{
    use UuidTrait;
}
```

### `HasTranslationsTrait`

[](#hastranslationstrait)

Adds a `translations` jsonb column for multi-locale field values.

```
$entity->setTranslation('es', 'name', 'Producto');
$entity->getTranslation('es', 'name'); // 'Producto'
```

### `ParameterTrait`

[](#parametertrait)

Adds a `parameters` jsonb column with recursive merge support.

```
$entity->setParameter('color', 'red');
$entity->getParameter('color'); // 'red'
$entity->setParameters(['size' => 'L'], force: false); // recursive merge
```

### `ObjectTrackNullableTrait` / `ObjectTrackRequiredTrait`

[](#objecttracknullabletrait--objecttrackrequiredtrait)

Adds `objectClass` and `objectId` columns to track which object a record belongs to. Use the nullable variant when the relation is optional.

---

Repository Traits
-----------------

[](#repository-traits)

### `BaseRepositoryTrait`

[](#baserepositorytrait)

```
$repo->save($entity);
$repo->remove($entity);
$repo->findByUuid($uuid);           // returns T|null
$repo->findOrFailByUuid($uuid);     // throws EntityNotFoundException
$repo->paginate($qb, $tableQuery, sortable: ['name'], searchable: ['name', 'email']);
```

### `TranslatableRepositoryTrait`

[](#translatablerepositorytrait)

```
$this->addTranslatedOrderBy($qb, 'p', 'name', $locale, 'ASC');
$this->addTranslatedSearch($qb, 'p', 'name', $searchTerm, $locale);
```

---

DTOs
----

[](#dtos)

### `TableQueryRequest`

[](#tablequeryrequest)

```
$query = TableQueryRequest::fromArray($request->query->all());
// $query->page, $query->perPage, $query->q, $query->sort, $query->dir
```

### `PaginatedResult`

[](#paginatedresult)

```
// Returned by BaseRepositoryTrait::paginate()
$result->data;       // array of entities
$result->total;      // int
$result->page;       // int
$result->perPage;    // int
$result->totalPages; // int (computed)
```

---

Value Objects
-------------

[](#value-objects)

All value objects are `final readonly`, normalize on construction and throw `ValueObjectException` on invalid input.

ClassValidates`Email`Valid email, lowercased`Phone`E.164-compatible (strips spaces/dashes)`Slug`Lowercase, `[a-z0-9-]`, 2–255 chars`Username``[a-zA-Z0-9_.-]`, 3–50 chars```
$email = new Email('  USER@Example.COM  '); // 'user@example.com'
$slug  = new Slug('My Product Name');        // 'my-product-name'
```

---

DQL Function
------------

[](#dql-function)

`TRANSLATE_FIELD_VALUE(column, 'field', :locale)` maps to `jsonb_extract_path_text(column, locale, field)`.

Useful for ordering and filtering on translated values stored in a jsonb `translations` column.

---

Requirements
------------

[](#requirements)

- PHP `^8.4`
- Symfony `^7.0 || ^8.0`
- `doctrine/orm` `^3.0`
- `doctrine/bundle` `^2.0`
- `gedmo/doctrine-extensions` `^3.0`
- `letkode/common-bundle` `^1.0`

---

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

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

2

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/562202fef9515226531f2d5c3b8cfc6a0a3a3bb61616204e56e3d93eaec3ed5f?d=identicon)[letkode.app](/maintainers/letkode.app)

---

Top Contributors

[![tjcalma](https://avatars.githubusercontent.com/u/4671171?v=4)](https://github.com/tjcalma "tjcalma (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/letkode-entity-traits-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/letkode-entity-traits-bundle/health.svg)](https://phpackages.com/packages/letkode-entity-traits-bundle)
```

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1155.2k](/packages/rcsofttech-audit-trail-bundle)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M373](/packages/easycorp-easyadmin-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M196](/packages/sulu-sulu)[kimai/kimai

Kimai - Time Tracking

4.7k8.7k1](/packages/kimai-kimai)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M711](/packages/sylius-sylius)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1715.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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