chamber-orchestra/doctrine-extensions-bundle

The symfony doctrine extensions bundle

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/chamber-orchestra/doctrine-extensions-bundle

v8.0.1 2026-01-04 19:28 UTC

This package is auto-updated.

Last update: 2026-01-04 19:36:47 UTC


README

A Symfony bundle that provides lightweight Doctrine extensions for common entity patterns and utility types. It includes reusable entity traits, a soft-delete filter, a custom decimal DBAL type, and a SQL random() DQL function.

Requirements

  • PHP ^8.4
  • Symfony FrameworkBundle
  • Doctrine ORM and DoctrineBundle

Installation

Install via Composer:

composer require chamber-orchestra/doctrine-extensions-bundle

Enable the bundle (if not using Symfony Flex auto-discovery):

// config/bundles.php
return [
    ChamberOrchestra\DoctrineExtensionsBundle\ChamberOrchestraDoctrineExtensionsBundle::class => ['all' => true],
];

Usage

Entity traits

Use the bundled traits in your Doctrine entities:

use ChamberOrchestra\DoctrineExtensionsBundle\Entity\IdTrait;
use ChamberOrchestra\DoctrineExtensionsBundle\Entity\ToggleTrait;
use ChamberOrchestra\DoctrineExtensionsBundle\Entity\SoftDeleteTrait;

class Article
{
    use IdTrait;
    use ToggleTrait;
    use SoftDeleteTrait;
}

Soft-delete filter

Register and enable the filter in Doctrine configuration, then disable per entity when needed:

$filter = $entityManager->getFilters()->enable('soft_delete');
$filter->disableForEntity(Article::class);

DQL random function

Register the function in Doctrine config and use it in DQL:

// doctrine.yaml
// doctrine:
//   orm:
//     dql:
//       numeric_functions:
//         random: ChamberOrchestra\DoctrineExtensionsBundle\Function\Random
$qb->select('a')->from(Article::class, 'a')->orderBy('random()');

Decimal DBAL type

Use the custom type for decimal precision and ensure Doctrine knows the type:

#[ORM\Column(type: 'decimal')]
private string $price;

Dependencies

Declared in composer.json:

  • doctrine/orm
  • doctrine/doctrine-bundle
  • symfony/framework-bundle

Running tests

composer test

This executes PHPUnit using phpunit.xml.dist.