PHPackages                             zenstruck/foundry - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. zenstruck/foundry

ActiveLibrary[Testing &amp; Quality](/categories/testing)

zenstruck/foundry
=================

A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.

v2.10.1(1mo ago)79613.7M↓41%112[28 issues](https://github.com/zenstruck/foundry/issues)[7 PRs](https://github.com/zenstruck/foundry/pulls)20MITPHPPHP &gt;=8.1CI passing

Since Jul 10Pushed 1w ago6 watchersCompare

[ Source](https://github.com/zenstruck/foundry)[ Packagist](https://packagist.org/packages/zenstruck/foundry)[ Docs](https://github.com/zenstruck/foundry)[ GitHub Sponsors](https://github.com/kbond)[ GitHub Sponsors](https://github.com/nikophil)[ RSS](/packages/zenstruck-foundry/feed)WikiDiscussions 2.x Synced 2d ago

READMEChangelog (10)Dependencies (68)Versions (137)Used By (20)

Foundry
=======

[](#foundry)

[![CI Status](https://github.com/zenstruck/foundry/workflows/CI/badge.svg)](https://github.com/zenstruck/foundry/actions?query=workflow%3ACI)[![Code Coverage](https://camo.githubusercontent.com/27a53f8228f91e1eac0c1875723f39dfcbf7c5d225085f3d4f4ee130312bb56f/68747470733a2f2f636f6465636f762e696f2f67682f7a656e73747275636b2f666f756e6472792f6272616e63682f6d61737465722f67726170682f62616467652e7376673f746f6b656e3d37374a49465953554335)](https://codecov.io/gh/zenstruck/foundry)[![Latest Version](https://camo.githubusercontent.com/cbe851d60b60596b7ad76e1039913e16a4ecdc47ecad688876d84f0a27a7a53a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a656e73747275636b2f666f756e6472792e737667)](https://packagist.org/packages/zenstruck/foundry)[![Downloads](https://camo.githubusercontent.com/272d201a13a1ec9eedb5d49a445217b707f79b7f63ce77ce40ad144a380b3feb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7a656e73747275636b2f666f756e647279)](https://packagist.org/packages/zenstruck/foundry)

"Fixtures you'll actually enjoy writing!"

Foundry turns fixture creation into a joy, via an expressive, auto-completable, on-demand fixtures system with Symfony and Doctrine:

```
$post = PostFactory::new() // Create the factory for Post objects
    ->published()          // Make the post in a "published" state
    ->create([             // create & persist the Post object
        'slug' => 'post-a' // This Post object only requires the slug field - all other fields are random data
    ])
;
```

The factories can be used inside [DoctrineFixturesBundle](https://symfony.com/bundles/DoctrineFixturesBundle/current/index.html)to load fixtures or inside your tests, [where it has even more features](https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#using-in-your-tests).

Foundry supports `doctrine/orm` (with [doctrine/doctrine-bundle](https://github.com/doctrine/doctrinebundle)), `doctrine/mongodb-odm` (with [doctrine/mongodb-odm-bundle](https://github.com/doctrine/DoctrineMongoDBBundle)) or a combination of these.

Want to watch a screencast 🎥 about it? Check out

**[Read the Documentation](https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html)**

**[Upgrade guide to v2](https://github.com/zenstruck/foundry/blob/v2.0.0/UPGRADE-2.0.md)**

How to contribute
-----------------

[](#how-to-contribute)

### Running the Test Suite

[](#running-the-test-suite)

The test suite of this library needs one or more databases, then it comes with a docker compose configuration.

Note

Docker and PHP installed locally (with `mysql`, `pgsql` &amp; `mongodb` extensions) is required.

You can start the containers and run the test suite:

```
# start the container
$ docker compose up --detach

# install dependencies
$ composer update

# run main testsuite (with "schema" reset database strategy)
$ ./phpunit

# run "reset-database" testsuite
$ ./phpunit --testsuite reset-database
```

### Overriding the default configuration

[](#overriding-the-default-configuration)

You can override default environment variables by creating a `.env.local` file, to easily enable permutations:

```
# .env.local

# change the database to postgreSQL...
DATABASE_URL="postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15"
# ...or to SQLite
DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"

MONGO_URL="" # disables Mongo
USE_DAMA_DOCTRINE_TEST_BUNDLE="1" # enables dama/doctrine-test-bundle
PHPUNIT_VERSION="11" # possible values: 9, 10, 11, 11.4

# test reset database with migrations,
# only relevant for "reset-database" testsuite
DATABASE_RESET_MODE="migrate"
MIGRATION_CONFIGURATION_FILE="tests/Fixture/MigrationTests/configs/migration-configuration.php"

# run test suite with postgreSQL
$ vendor/bin/phpunit
```

The `.env.local` file can also be used to override the port of the database containers, if it does not meet your local requirements. You'll also need to override docker compose configuration:

Here is an example to use MySQL on port `3308`:

```
# docker-compose.override.yml
version: '3.9'

services:
    mysql:
        ports:
            - "3308:3306"
```

```
# .env.local
DATABASE_URL="mysql://root:1234@127.0.0.1:3308/foundry_test?serverVersion=5.7.42"
```

### Run the tests locally faster

[](#run-the-tests-locally-faster)

As long as you don't want to test Mongo, you can use the following `.env.local` file to run the tests faster locally:

```
# dama/doctrine-test-bundle makes Foundry testsuite really faster
USE_DAMA_DOCTRINE_TEST_BUNDLE="1"

# using both ODM and ORM makes the "reset db" mechanism slower
MONGO_URL=""

# Use the last version of PHPUnit
PHPUNIT_VERSION="12"

# Enable all features of Foundry
USE_FOUNDRY_PHPUNIT_EXTENSION="1"
```

"maker" tests are also quite slow, so you can skip them with using the following command:

```
$ ./phpunit --exclude-group=maker
```

Enjoy blazing fast tests! 🚀

### Running the documentation linter locally

[](#running-the-documentation-linter-locally)

This section provides guidance on how to run the documentation linter, contained within a Docker image, locally on your machine. This linter is designed to verify and ensure that the document syntax adheres to the required standards.

The following command runs the linter in the local directory:

```
docker run --rm -it -e DOCS_DIR='/docs' -v ${PWD}/docs:/docs  oskarstark/doctor-rst:latest
```

Credit
------

[](#credit)

The [AAA](https://www.thephilocoder.com/unit-testing-aaa-pattern/) style of testing was first introduced to me by [Adam Wathan's](https://adamwathan.me/) excellent [Test Driven Laravel Course](https://course.testdrivenlaravel.com/). The inspiration for this libraries API comes from [Laravel factories](https://laravel.com/docs/master/database-testing)and [christophrumpel/laravel-factories-reloaded](https://github.com/christophrumpel/laravel-factories-reloaded).

Security Policy
---------------

[](#security-policy)

If you discover a security vulnerability, please do not open a public issue or pull request. Instead, please review this repository's [Security Policy](https://github.com/zenstruck/foundry/security) for instructions on how to report it responsibly.

###  Health Score

77

—

ExcellentBetter than 100% of packages

Maintenance94

Actively maintained with recent releases

Popularity71

Solid adoption and visibility

Community48

Growing community involvement

Maturity82

Battle-tested with a long release history

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~16 days

Recently: every ~34 days

Total

135

Last Release

8d ago

Major Versions

v1.38.4 → v2.3.22025-02-01

v1.38.5 → 2.3.x-dev2025-03-31

v1.38.6 → v2.4.02025-04-14

1.x-dev → v2.5.22025-05-26

v2.9.1 → 3.x-dev2026-02-10

PHP version history (5 changes)v1.0.0PHP &gt;=7.2.5

v1.8.0PHP &gt;=7.2.12

v1.24.0PHP &gt;=8.0

v2.0.0PHP &gt;=8.1

3.x-devPHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/707369cc916e0ea1aacbf077dcba464f611cef879f024d8944311a54a15224b3?d=identicon)[kbond](/maintainers/kbond)

---

Top Contributors

[![nikophil](https://avatars.githubusercontent.com/u/10139766?v=4)](https://github.com/nikophil "nikophil (465 commits)")[![kbond](https://avatars.githubusercontent.com/u/127811?v=4)](https://github.com/kbond "kbond (386 commits)")[![wouterj](https://avatars.githubusercontent.com/u/749025?v=4)](https://github.com/wouterj "wouterj (15 commits)")[![OskarStark](https://avatars.githubusercontent.com/u/995707?v=4)](https://github.com/OskarStark "OskarStark (11 commits)")[![HypeMC](https://avatars.githubusercontent.com/u/2445045?v=4)](https://github.com/HypeMC "HypeMC (10 commits)")[![Chris53897](https://avatars.githubusercontent.com/u/7104259?v=4)](https://github.com/Chris53897 "Chris53897 (7 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (5 commits)")[![BackEndTea](https://avatars.githubusercontent.com/u/14289961?v=4)](https://github.com/BackEndTea "BackEndTea (4 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![gnito-org](https://avatars.githubusercontent.com/u/70450336?v=4)](https://github.com/gnito-org "gnito-org (4 commits)")[![jmsche](https://avatars.githubusercontent.com/u/3929498?v=4)](https://github.com/jmsche "jmsche (4 commits)")[![GrinWay](https://avatars.githubusercontent.com/u/175572154?v=4)](https://github.com/GrinWay "GrinWay (3 commits)")[![mpiot](https://avatars.githubusercontent.com/u/10453508?v=4)](https://github.com/mpiot "mpiot (3 commits)")[![jdreesen](https://avatars.githubusercontent.com/u/424602?v=4)](https://github.com/jdreesen "jdreesen (3 commits)")[![javiereguiluz](https://avatars.githubusercontent.com/u/73419?v=4)](https://github.com/javiereguiluz "javiereguiluz (3 commits)")[![seb-jean](https://avatars.githubusercontent.com/u/12116264?v=4)](https://github.com/seb-jean "seb-jean (3 commits)")[![smnandre](https://avatars.githubusercontent.com/u/1359581?v=4)](https://github.com/smnandre "smnandre (3 commits)")[![VincentLanglet](https://avatars.githubusercontent.com/u/9052536?v=4)](https://github.com/VincentLanglet "VincentLanglet (3 commits)")[![jschaedl](https://avatars.githubusercontent.com/u/1880467?v=4)](https://github.com/jschaedl "jschaedl (2 commits)")[![NorthBlue333](https://avatars.githubusercontent.com/u/43409865?v=4)](https://github.com/NorthBlue333 "NorthBlue333 (2 commits)")

---

Tags

doctrinefactoryfakerfixturessymfonytestsymfonytestfactorydevFixturefakerdoctrine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/zenstruck-foundry/health.svg)

```
[![Health](https://phpackages.com/badges/zenstruck-foundry/health.svg)](https://phpackages.com/packages/zenstruck-foundry)
```

###  Alternatives

[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M574](/packages/shopware-core)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M339](/packages/api-platform-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
