DoctrineFixturesBundle

Symfony integration for Doctrine Data Fixtures to load sample and test data into your database

Library
Composer
v4.3.1
2,531stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
76/100Good
Development Activity84
Maintenance60
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
83/100Excellent
Architecture82
Code Quality88
Innovation78
Learning Curve85

DoctrineFixturesBundle is the official Symfony bundle that integrates the Doctrine Data Fixtures library, letting you programmatically load sample data into any Doctrine ORM-backed database. You define plain PHP fixture classes that extend a base Fixture class and persist entities, then run a single console command to populate your schema.

It is the standard way Symfony applications seed development databases and prepare deterministic data for automated tests. The bundle handles fixture discovery, dependency ordering, groups, purging strategies, and entity-manager selection so teams can keep their seed data in version control alongside their code.

What You Get

  • A doctrine:fixtures:load console command with append, dry-run, group, and entity-manager options
  • A base Fixture class and interfaces (ORMFixtureInterface, FixtureGroupInterface, DependentFixtureInterface) for structuring seed data
  • Automatic fixture discovery and service registration through a Symfony compiler pass
  • Pluggable purger factories to control how existing data is cleared before loading
  • Support for multiple entity managers and shared object references across fixtures

Common Use Cases

  • Seeding a local development database with realistic sample data
  • Providing deterministic starting data for integration and functional tests
  • Bootstrapping demo environments with predictable content
  • Loading reference/lookup data such as roles, categories, or country lists

Under The Hood

Architecture - At boot, DoctrineFixturesBundle registers a Symfony extension (DoctrineFixturesExtension) and two compiler passes. FixturesCompilerPass collects every service tagged as a fixture and hands them to SymfonyFixturesLoader/FixturesProvider, while PurgerFactoryCompilerPass gathers pluggable purger factories. The LoadDataFixturesDoctrineCommand (doctrine:fixtures:load) then resolves the target entity manager from the ManagerRegistry, builds an ORMExecutor (or DryRunORMExecutor), applies the selected purger, and executes the ordered fixture set.

Tech Stack - Pure PHP 8.1+ targeting Symfony 6.4/7/8 and Doctrine ORM 2.14+/3, built on doctrine/data-fixtures, symfony/console, symfony/dependency-injection, and symfony/http-kernel. Development tooling includes PHPUnit, PHPStan, and the Doctrine Coding Standard (phpcs).

Code Quality - The codebase is small, strictly typed (declare(strict_types=1)), and enforced by PHPStan and phpcs configurations. It ships an integration test suite (tests/IntegrationTest.php with a dedicated IntegrationTestKernel) that boots a real kernel to exercise fixture loading and purging end to end.

API Design - The public surface is deliberately minimal: extend the base Fixture class, implement load(ObjectManager $manager), and optionally add DependentFixtureInterface or FixtureGroupInterface. Getting started requires almost no boilerplate, and the documentation on symfony.com covers ordering, references, groups, and services thoroughly.

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