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
Requires
- php: ^8.4
- ext-intl: *
- doctrine/common: ^3.0
- doctrine/doctrine-bundle: 3.2.*
- doctrine/orm: ^3.0
- symfony/clock: 8.0.*
- symfony/config: 8.0.*
- symfony/dependency-injection: 8.0.*
- symfony/framework-bundle: 8.0.*
- symfony/options-resolver: 8.0.*
- symfony/runtime: 8.0.*
- symfony/uid: 8.0.*
Requires (Dev)
- phpunit/phpunit: ^12.5
- symfony/test-pack: ^1.2
Conflicts
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/ormdoctrine/doctrine-bundlesymfony/framework-bundle
Running tests
composer test
This executes PHPUnit using phpunit.xml.dist.