Doctrine entity traits, repository traits, value objects and DQL utilities for Symfony applications.
composer require letkode/orm-toolkit-bundleSymfony Flex will register the bundle automatically. If not using Flex, add it manually:
// config/bundles.php
return [
Letkode\OrmToolkitBundle\LetkodeOrmToolkitBundle::class => ['all' => true],
];The bundle automatically registers the TRANSLATE_FIELD_VALUE Doctrine DQL function via PrependExtensionInterface.
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\OrmToolkitBundle\Trait\Entity\UuidTrait;
#[ORM\Entity]
class Product
{
use UuidTrait;
}Adds a translations jsonb column for multi-locale field values.
$entity->setTranslation('es', 'name', 'Producto');
$entity->getTranslation('es', 'name'); // 'Producto'Adds a parameters jsonb column with recursive merge support.
$entity->setParameter('color', 'red');
$entity->getParameter('color'); // 'red'
$entity->setParameters(['size' => 'L'], force: false); // recursive mergeAdds objectClass and objectId columns to track which object a record belongs to. Use the nullable variant when the relation is optional.
Query/filter/pagination params are provided by letkode/query-filter-bundle.
use Letkode\QueryFilterBundle\Request\FilterQueryRequest;
$repo->save($entity);
$repo->remove($entity);
$repo->findByUuid($uuid); // returns T|null
$repo->findOrFailByUuid($uuid); // throws EntityNotFoundException
$repo->paginate($qb, $query, sortable: ['name'], searchable: ['name', 'email']);
// $query is a Letkode\QueryFilterBundle\Request\FilterQueryRequest$this->addTranslatedOrderBy($qb, 'p', 'name', $locale, 'ASC');
$this->addTranslatedSearch($qb, 'p', 'name', $searchTerm, $locale);All value objects are final readonly, normalize on construction and throw ValueObjectException on invalid input.
| Class | Validates |
|---|---|
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'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.
- PHP
^8.4 - Symfony
^7.0 || ^8.0 doctrine/orm^3.0doctrine/bundle^2.0gedmo/doctrine-extensions^3.0letkode/common-bundle^1.0letkode/query-filter-bundle^1.0
MIT — see LICENSE.