stof/doctrine-extensions-bundle
gedmo/doctrine-extensions, a widely adopted library for Doctrine ORM enhancements (e.g., timestamps, slugs, trees, soft deletes, etc.). It fits seamlessly into Symfony’s bundle-based architecture, leveraging Doctrine’s event system without requiring custom listeners.Timestampable for Post but not User).stof/doctrine-extensions-bundle) and configuration via config/packages/stof_doctrine_extensions.yaml is standardized and well-documented.doctrine/doctrine-bundle (Symfony’s core) and doctrine/orm (v2.10+).gedmo/doctrine-extensions (v3.7+), which may introduce minor version conflicts if other packages pin older Doctrine versions.Timestampable or SoftDeleteable modify schema (e.g., adding created_at, updated_at, deleted_at columns). Migrations must be planned to avoid downtime.NestedSet) requires indexes for performance, which may need manual tuning.| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Doctrine Version Lock | Medium | Pin gedmo/doctrine-extensions to a stable range (e.g., ^3.7) in composer.json. |
| Schema Migration | High | Use Doctrine Migrations (make:migration) or custom SQL for complex extensions (e.g., Tree). |
| Performance Overhead | Low | Benchmark queries with Tree/NestedSet; consider denormalization for read-heavy workloads. |
| Deprecation Risk | Low | Bundle is actively maintained (last release: 2026), but gedmo/doctrine-extensions is community-driven. Monitor GitHub issues. |
| Symfony 7+ Compatibility | Medium | Test with Symfony’s latest LTS; some extensions (e.g., Sortable) may need custom event subscribers. |
Timestampable for auditing, SoftDeleteable for retention policies).Tree for flat data).Tree performance is poor, consider materialized paths or adjacency lists.assertSoftDeleted()).Timestampable/SoftDeleteable events).gedmo/doctrine-extensions directly.created_at/updated_at).@ORM\GeneratedValue vs. Timestampable).composer require stof/doctrine-extensions-bundle
composer.json:
"require": {
"stof/doctrine-extensions-bundle": "^1.7",
"gedmo/doctrine-extensions": "^3.7"
}
config/bundles.php:
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
config/packages/stof_doctrine_extensions.yaml:
stof_doctrine_extensions:
orm:
default:
timestampable: true
softdeleteable: true
# ... other extensions
use Gedmo\Mapping\Annotation as Gedmo):
/**
* @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
*/
class Post {}
php bin/console make:migration
php bin/console doctrine:migrations:migrate
php bin/console doctrine:schema:validate
SoftDeleteable queries):
$repository->createQueryBuilder('p')
->where('p.deletedAt IS NULL')
->getQuery();
Tree extensions.WHERE deleted_at IS NULL).doctrine/doctrine-fixtures-bundle to include new fields.Timestampable, Slugable).SoftDeleteable, Tree) in a dedicated release.Tree).SoftDeleteable behavior via events).stof/doctrine-extensions-bundle for Symfony 8+ compatibility.gedmo/doctrine-extensions for breaking changes (e.g., annotation deprecations).composer why-not to debug dependency issues.doctrine:
dbal:
logging: true
stof_doctrine_extensions.event_listener logs for extension events.default_timezone in config/packages/doctrine.yaml).MaterializedPath).MaterializedPath for read-heavy workloads (avoid NestedSet for >10k nodes).deleted_at for large tables.Timestampable add overhead to INSERTHow can I help you explore Laravel packages today?