Doctrine Extensions

Behavioral extensions for Doctrine ORM and MongoDB ODM: Sluggable, Tree, Translatable, Timestampable, SoftDeleteable and more.

Library
Composer
vv3.22.1
4,141stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
79/100Good
Development Activity68
Maintenance64
Community84
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture86
Code Quality85
Innovation78
Learning Curve68

Doctrine Extensions (the gedmo/doctrine-extensions package) is a collection of behavioral extensions for Doctrine ORM and MongoDB ODM. It hooks into Doctrine’s event system to add common, reusable behaviors to your entities and documents without cluttering your domain logic, handling records transparently as they are flushed.

The package bundles widely used behaviors such as Sluggable, Tree (nested set, closure, and materialized path strategies), Translatable, Timestampable, Blameable, SoftDeleteable, Sortable, Loggable, and Uploadable. Behaviors are attached through mapping annotations, attributes, XML, or YAML and driven by event listeners, keeping the implementation decoupled from the entities themselves.

What You Get

  • A suite of behaviors including Sluggable, Tree, Translatable, Timestampable, Blameable, SoftDeleteable, Sortable, Loggable, Uploadable, and more
  • Support for both Doctrine ORM and MongoDB ODM through a shared listener architecture
  • Multiple mapping formats: PHP attributes, annotations, XML, and YAML
  • Multiple tree strategies including nested set, closure table, and materialized path
  • Reusable traits and interfaces so entities can opt into behaviors with minimal boilerplate

Common Use Cases

  • Automatically generating and maintaining URL-friendly slugs from entity fields
  • Managing hierarchical data such as categories or menus with nested-set or materialized-path trees
  • Storing entity field translations and stamping created/updated timestamps and authors automatically

Under The Hood

Architecture - The package is organized by behavior, with each extension (Sluggable, Tree, Translatable, Timestampable, Blameable, SoftDeleteable, Sortable, Loggable, Uploadable, and others) living in its own namespace under src/. Every behavior generally provides an event listener that subscribes to Doctrine’s onFlush, prePersist, and related lifecycle events, plus a mapping driver and interfaces/traits entities implement. A shared AbstractTrackingListener and Mapping layer unify configuration across the ORM and MongoDB ODM. Tech Stack - PHP 7.4/8.x with dependencies on doctrine/persistence, doctrine/event-manager, doctrine/collections, symfony/cache, and symfony/string. It targets Doctrine ORM and MongoDB ODM and uses PSR cache/clock interfaces. Code Quality - The project enforces coding standards and QA via GitHub Actions workflows (continuous integration, quality assurance, coding standards), ships a comprehensive test suite, and follows Doctrine’s conventions; the 3.0 line modernized the codebase for current PHP and Doctrine versions. API Design - Behaviors are opt-in through mapping metadata (attributes, annotations, XML, or YAML) and traits, so entities stay clean and the wiring is declarative. The main friction is registering listeners with the EventManager and configuring mapping drivers, which is well documented per behavior.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search