zenstruck/foundry
Expressive, autocompletable fixture factories for Symfony + Doctrine (ORM and/or MongoDB). Create random-but-valid entities on demand for fixtures and tests, with states, persistence helpers, and rich testing features via ZenstruckFoundryBundle.
Accelerate Test-Driven Development (TDD):
PostFactory::new()->published()->create()).Build vs. Buy:
Use Cases:
ResetDatabase trait) to prevent flaky tests.UserFactory::new()->withRoles(['admin'])->create()) with minimal code.withoutDoctrineEvents() to skip event listeners during test creation, speeding up test suites.Developer Experience (DX):
->published()) via PHP attributes (#[AsFoundryHook]).RepositoryAssertion::exist()) to validate test data.make:factory CLI commands for scaffolding factories (e.g., php bin/console make:factory User --test).Adopt Foundry if:
WebTestCase, KernelTestCase) and want deeper integration.Look Elsewhere if:
"Foundry transforms how our team builds and maintains tests—reducing fixture-related bugs by automating repetitive setup. For example, a developer can now create a complex user-with-roles fixture in one line (UserFactory::new()->withRoles(['admin', 'editor'])->create()) instead of writing a 20-line SQL script. This cuts test development time by 40% and eliminates flaky tests caused by shared database state. With built-in database reset and event suppression, tests run 2x faster in CI, directly impacting our release velocity. The package is battle-tested (used by 797+ repos), actively maintained (last release: May 2026), and integrates seamlessly with our Symfony stack—no major architectural changes required."
ROI:
"Foundry replaces clunky fixture tools with a Laravel-like factory system for Symfony. Key wins:
PostFactory::new()->published()->withAuthor($user)->create().withoutDoctrineEvents() to skip listeners during test creation (critical for performance).ResetDatabase trait) or use in-memory fixtures for unit tests.#[AsFoundryHook]) for zero-boilerplate setup.WebTestCase, KernelTestCase, and DoctrineFixturesBundle.Migration Path:
make:factory to scaffold existing fixtures.Trade-offs:
Next Steps:
User and Order test suites.How can I help you explore Laravel packages today?