doctrine/data-fixtures
Manage and load data fixtures for any Doctrine object manager
Repository Health
Technical Analysis
doctrine/data-fixtures is a library that provides a simple, structured way to define and load data fixtures for Doctrine’s ORM and ODM. Fixtures are plain PHP classes that populate a database (or document store) with known data, which is essential for reproducible tests, local development seeding, and demos.
Beyond basic loading, it supports ordering fixtures explicitly, declaring dependencies between them, sharing entity references across fixtures, purging existing data before loading, and executing everything against any Doctrine object manager. It underpins the popular Symfony DoctrineFixturesBundle and is one of the most widely installed packages in the PHP ecosystem.
What You Get
- A FixtureInterface and AbstractFixture base for writing fixture classes
- A Loader that discovers and organizes fixtures from a directory or classes
- Ordered and dependent fixture execution for correct load sequencing
- A reference repository for sharing created entities across fixtures
- Purgers to clear existing data before loading, for both ORM and ODM
Common Use Cases
- Seeding a database with known data for automated test suites
- Populating a local development environment with realistic sample data
- Loading demo data for staging or presentation environments
- Managing complex, interdependent seed data with a defined load order
Under The Hood
Architecture — The library separates fixture definition from execution. Fixtures implement FixtureInterface (often via AbstractFixture, which adds reference-sharing) and may implement OrderedFixtureInterface or DependentFixtureInterface to control sequencing. A Loader (src/Loader.php) collects fixture instances and resolves their order, an Executor (src/Executor) drives loading against a specific object manager, a Purger (src/Purger) clears existing records first, and a ProxyReferenceRepository lets fixtures store and retrieve created entities by name so later fixtures can reference earlier ones. Events allow hooking into the load lifecycle. Tech Stack — Modern PHP depending on doctrine/persistence for the object-manager abstraction and psr/log, with optional integration for both the Doctrine ORM and MongoDB ODM; tests run under PHPUnit via GitHub Actions CI. Code Quality — A mature, actively maintained codebase (hundreds of commits, ongoing releases) with clear interface segregation (separate interfaces for ordering, dependencies, and shared fixtures), a dedicated exception hierarchy, and comprehensive test coverage. API Design — The API is small and idiomatic: implement load(ObjectManager $manager) in a fixture, optionally add ordering/dependency interfaces, use addReference/getReference to link entities, and run through a Loader and Executor. This composes cleanly and is familiar to Doctrine users, which is why the higher-level Symfony bundle builds directly on it.
Used by 2 apps in this directory
Mautic
Automation · Marketing · Ecommerce
The world's largest open source marketing automation platform — own your data, run multi-channel campaigns, and escape vendor lock-in forever.
wallabag
Bookmarks Archiving
Self-hosted read-it-later app that saves clean, ad-free articles from any webpage for distraction-free reading across all your devices.