NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #844 most downloaded on Packagist
A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.
Latest stable
v2.16.0
Last release 13 days ago
09 Nov 2026
Release timing varies
gaps range from 8 days to 3 months
Nearly every release is documented
notes for 60 of the last 60 stable releases
Nothing withdrawn
no release was ever pulled
6 years old
144 releases · first in 2020
Drag across the ruler to compare, or tap a release to open it.
…(#1200) by @nikophil 0db83e5 chore: Replace deprecated rector rule with own rule (#1198) by @Gared, @nikophil a00d6d5 ci: run MySQL as a service conta…
a4a3903 ci: make the benchmark comparison resilient to runner noise (#1201) by @nikophil
1c9af86 refactor: share the parent-walking property lookup (#1202) by @nikophil
e141c8b feat(maker): generate a default value for ulid fields (#1194) by @seb-jean
45d6d0a fix: support inherited private property (#1195) by @Exalyon
66c5306 fix(maker): support entities with nested embeddables (#1199) by @Lars-
9279d09 test: configure the DBAL schema manager factory in AutoDatabaseResetterTest (#1200) by @nikophil
0db83e5 chore: Replace deprecated rector rule with own rule (#1198) by @Gared, @nikophil
a00d6d5 ci: run MySQL as a service container (#1196) by @nikophil
cbf809e fix(maker): generate randomElements() for array-of-enum fields (#1192) by @seb-jean
4fba8f5 test: fix flaky FakerSeedIsNotResetDuringRunKernelTest (#1193) by @nikophil
8b46149 feat: auto ORM reset mode (#934) by @kbond 0360bae test: don't rely on kernel shutdown leaving cycles uncollected (#1189) by @kbond
Your coding agent can read these notes before it upgrades. Set up the MCP server →
8b46149 feat: auto ORM reset mode (#934) by @kbond
0360bae test: don't rely on kernel shutdown leaving cycles uncollected (#1189) by @kbond
October 26th, 2026 - v2.14.1...v2.15.0
auto ORM reset mode (#934) by @kbond73e96d0 fix: wire inverse collections left uninitialized by the constructor (#1187) by @nikophil
73e96d0 fix: wire inverse collections left uninitialized by the constructor (#1187) by @nikophil
October 8th, 2026 - v2.14.0...v2.14.1
c8ea565 Actually run the reset-database testsuite in migrate mode (#1186) by @nikophil 7dd9a73 Support Behat 4 in the Behat sub-package (#1182) by @ni
c8ea565 Actually run the reset-database testsuite in migrate mode (#1186) by @nikophil 7dd9a73 Support Behat 4 in the Behat sub-package (#1182) by @nikophil b3ff36b fix: honor indexBy when wiring inverse collections (#1178) by @nikophil 8e98898 fix: re-enable DAMA static connections and stop the run when the first database reset fails (#1180) by @Amoifr 5c2f469 feat: load the stories of foundry:load-fixtures in a transaction (#1173) by @Amoifr 5508c3a ci: ignore the Psalm AfterExpressionAnalysisInterface in the BC check (#1179) by @nikophil 7d3b7aa Fix the namespace of the persistence helper functions in the docs (#1171) by @Amoifr
12bfb66 minor: upgrade PHPStan to 2.2 (#1168) by @nikophil d67f898 feat: honor factory state when a create helper is called on an instance (#1164) by
12bfb66 minor: upgrade PHPStan to 2.2 (#1168) by @nikophil d67f898 feat: honor factory state when a create helper is called on an instance (#1164) by @Amoifr, @claude 5b0781d fix(maker): generate clean code without relying on php-cs-fixer (#1169) by @nikophil 12e900b minor: fix SYMFONY_REQUIRE wildcard in the code coverage job (#1165) by @nikophil eb2f4e0 docs: disambiguate factory "attributes" from native PHP attributes (#1159) by @Amoifr 6541af3 feat: add Factory::memoize() and FactoryCollection::memoize() (#1161) by @Amoifr cf8a783 minor: allow doctrine/doctrine-migrations-bundle ^4 in tests by @nikophil 493688f Document valid string values for orm.reset.mode (#1163) by @derrabus 65b9f60 ci: fix the BC check when a branch modifies src/Test/Behat (#1160) by @nikophil
006e433 fix: hydrate snapshots with deepclone_hydrate() (requires symfony/polyfill-deepclone ^1.42) (#1149) by @kabylixx, @nikophil 997340f fix: give
006e433 fix: hydrate snapshots with deepclone_hydrate() (requires symfony/polyfill-deepclone ^1.42) (#1149) by @kabylixx, @nikophil 997340f fix: give each test its own faker seed (#1158) by @nikophil b5cea45 docs: add CLAUDE.md (#1157) by @nikophil, @claude
August 26th, 2026 - v2.12.0...v2.12.1
9ab871f feat: load multiple groups/stories with foundry:load-fixtures (#1138) by @podoko
9ab871f feat: load multiple groups/stories with foundry:load-fixtures (#1138) by @podoko
August 14th, 2026 - v2.11.4...v2.12.0
ce5f32d fix(behat): pass null through by-type transforms for optional multiline arguments (#1155) by @nikophil 4b22a12 ci: test against Symfony 8.1 in
ce5f32d fix(behat): pass null through by-type transforms for optional multiline arguments (#1155) by @nikophil 4b22a12 ci: test against Symfony 8.1 instead of EOL 8.0 (#1156) by @nikophil, @claude
August 13th, 2026 - v2.11.3...v2.11.4
e70f7e9 feat(behat): resolve id placeholders in PyString and table arguments (#1152) by @nikophil, @claude b0effe0 refactor(behat): remove FoundryCall
e70f7e9 feat(behat): resolve id placeholders in PyString and table arguments (#1152) by @nikophil, @claude b0effe0 refactor(behat): remove FoundryCallFilter and FoundryTableNode (#1151) by @nikophil, @claude
August 5th, 2026 - v2.11.2...v2.11.3
2624ee7 fix: prevent flushes from corrupting tracked objects reset as lazy ghosts (ORM 2 / ODM without native lazy objects). (#1147) by @nikophil f26a
2624ee7 fix: prevent flushes from corrupting tracked objects reset as lazy ghosts (ORM 2 / ODM without native lazy objects). (#1147) by @nikophil f26a1c7 minor: re-enable BC check by stripping the Behat subpackage from compared revisions (#1150) by @nikophil, @claude c4dd64a fix(behat): fix package split workflow by @nikophil
August 3rd, 2026 - v2.11.1...v2.11.2
eaabcd1 minor: remove clone in autorefresh() and fix stale tracked objects with ORM 2 (#1146) by @nikophil, @claude 0b0f065 minor: reuse PersistenceMa
eaabcd1 minor: remove clone in autorefresh() and fix stale tracked objects with ORM 2 (#1146) by @nikophil, @claude
0b0f065 minor: reuse PersistenceManager::reattach() and clean up refresh()/autorefresh() (#1144) by @nikophil, @claude
02c1b66 fix(ci): explicitly set matrix defaults in include entries (#1143) by @nikophil, @claude
81abe19 fix: global state should always be reatached in Doctrine (#1142) by @nikophil
c256db4 fix: global state should not be accessed when persistence is not available (#1141) by @nikophil
bc4c489 fix: introduce PersistenceManager::reattach() (#1140) by @nikophil
ec03220 feat(behat): follow foundry tags and mark the integration as experimental (#1137) by @nikophil
b69cde4 feat(behat): fix composer dependencies by @nikophil
24c00f7 minor(behat): bump foundry ^2.11 by @nikophil
3a13443 feat(behat): --lowest run should use doctrine/orm ^2 (#1136) by @nikophil ece8617 feat(behat): use specific PAT for split by @nikophil 9d36994
3a13443 feat(behat): --lowest run should use doctrine/orm ^2 (#1136) by @nikophil
ece8617 feat(behat): use specific PAT for split by @nikophil
9d36994 fix(behat): split subtree needs correct PAT by @nikophil
7ae1e71 fix(behat): make symlink-vendor.sh a no-op outside the monorepo (#1085) by @nikophil
06a514a chore(behat): exclude dev-only files from the split package dist (#1085) by @nikophil
1681d55 chore(behat): untrack composer.lock, already gitignored (#1085) by @nikophil
b307efe ci(behat): trigger the Behat workflow on main-package changes (#1085) by @nikophil
b20d8b2 test(behat): specify @withFixture semantics in disabled reset mode (#1085) by @nikophil
bff4466 test(behat): exercise every wording variant of the property assertion steps (#1085) by @nikophil
6c43019 test(behat): fix contradictory scenario title in disabled-mode feature (#1085) by @nikophil
8337ae9 test(behat): turn three registry has() calls into real assertions (#1085) by @nikophil
f0cf153 test(behat): cover the FoundryExtension configuration validation matrix (#1085) by @nikophil
69e67e0 fix(behat): drop @internal from the documented injection points (#1085) by @nikophil
0d754d0 docs: document the shared-container contract of BehatServicesCompilerPass (#1085) by @nikophil
252719d fix(behat): replace the Configuration booted by the bundle at exercise start (#1085) by @nikophil
8b7f771 fix(behat): do not reload global stories under DAMA's native extension (#1085) by @nikophil
4dd59ac fix(behat): reset the database at suite start in manual mode with DAMA support (#1085) by @nikophil
00feb6a fix(behat): fail loudly when DAMA support is enabled without the bundle (#1085) by @nikophil
91fd887 fix(behat): support quoted names in object()/lastObject() placeholders (#1085) by @nikophil
5c71353 fix(behat): register falsy object names like "0" at creation (#1085) by @nikophil
2fb1775 fix(behat): allow Background blocks to re-register named objects across scenarios (#1085) by @nikophil
b84c9ce fix(behat): resolve the identifier field name for lastId/lastObject placeholders (#1085) by @nikophil
42a234f fix(behat): normalize object identifiers in assertSameObject comparisons (#1085) by @nikophil
3df8b3f fix: only store in ObjectRegistry when actually running Behat (#1085) by @nikophil
6446224 feat(behat): replace step translations with trait-based context composition (#1085) by @nikophil
1725b6a feat(behat): prefix Behat transformers with "foundry:" (#1085) by @nikophil
dacf86a feat: database-backed id placeholders and assertion steps (#1085) by @nikophil
b24a1a9 fix: few fixes after agentic review (#1085) by @nikophil
0e11dd8 feat: override steps using translation (#1085) by @nikophil
800abc4 docs: clarify ref(type, name) syntax as an escape hatch (#1085) by @nikophil, @claude
f33dbcf feat: support UUID-based entity ids in ObjectRegistry (#1085) by @nikophil, @claude
c312ab9 fix: allow quoted object names starting with digits in regex patterns (#1085) by @nikophil, @claude
d46d219 fix: improve error messages in AbstractFoundryContext (#1085) by @nikophil, @claude
f609e65 perf: optimize class-to-factory lookups with index map in FactoryShortNameResolver (#1085) by @nikophil, @claude
8fef5a0 refactor: extract table normalization into private methods in FoundryCallFilter (#1085) by @nikophil, @claude
743eaf5 chore: zenstruck/foundry-behat a subpackage (#1084) (#1085) by @nikophil
8776ae9 feat/behat context (#1083) (#1085) by @nikophil
Previously, objects created by nested factories were passed to $em->persist() *during* the creation of the object graph. Their PrePersist listeners co
PrePersist listeners is no longer visible from hooks with default priorityPreviously, objects created by nested factories were passed to $em->persist() during the
creation of the object graph. Their PrePersist listeners could therefore observe — and even
corrupt (#1115) — a half-built graph, but it also meant their side effects (e.g. a field computed
in the listener) were already applied when your afterInstantiate() hooks ran.
Persistence is now deferred until the whole object graph is instantiated and wired, so hooks with
default priority run before any lifecycle event has been triggered. If one of your hooks reads
state computed by a PrePersist listener, give it a priority lower than
PersistentObjectFactory::PRIORITY_SCHEDULE_FOR_INSERT:
use Zenstruck\Foundry\Persistence\PersistentObjectFactory;
OrderItemFactory::new()
->afterInstantiate(function(OrderItem $item): void {
// computed in Order's PrePersist listener — visible here, on a fully wired graph
$item->setProcess($item->getOrder()->getProcess());
}, priority: PersistentObjectFactory::PRIORITY_SCHEDULE_FOR_INSERT - 1);
c851f6d fix: defer `$em->persist()` until the object graph is wired + natural accessor directionality (#1134) by @nikophil
[Full Change List](https://github.com/zenstruck/foundry/compare/v2.10.2...v2.10.3)
July 20th, 2026 - v2.10.2...v2.10.3
$em->persist() until the object graph is wired + natural accessor directionality (#1134) by @nikophil1ad45ac fix: withoutDoctrineEvents() should not remove loadClassMetadata listeners (#1133) by @nikophil 5553b63 fix: withoutDoctrineEvents should work
1ad45ac fix: withoutDoctrineEvents() should not remove loadClassMetadata listeners (#1133) by @nikophil
5553b63 fix: withoutDoctrineEvents should work with nested entities (#1132) by @nikophil
6917146 chore: fix Roave BC check (composer >= 2.9.8) and restrict phpunit < 13.2 (#1127) by @nikophil
d9ed62b doc: add README Security Policy section (#1123) by @Copilot
July 19th, 2026 - v2.10.1...v2.10.2
withoutDoctrineEvents() should not remove loadClassMetadata listeners (#1133) by @nikophilbc10d82 fix: withoutDoctrineEvents should do nothgin in unit tests (#1121) by @VincentLanglet
bc10d82 fix: withoutDoctrineEvents should do nothgin in unit tests (#1121) by @VincentLanglet
May 19th, 2026 - v2.10.0...v2.10.1
withoutDoctrineEvents should do nothgin in unit tests (#1121) by @VincentLangletdb2b673 fix: use full semver versions for PHPUnit requirements (#1118) by @nikophil d109883 Update warning message for Foundry v2 documentation (#1113
db2b673 fix: use full semver versions for PHPUnit requirements (#1118) by @nikophil
d109883 Update warning message for Foundry v2 documentation (#1113) by @gisostallenberg
31c90dd Minor doc fix (#1117) by @javiereguiluz
11f55e7 feat: throw when withoutDoctrineEvents() is called within flush_after() (#1111) by @nikophil
f81db0d feat: add withoutDoctrineEvents() to suppress listeners during factory create (#1109) by @seb-jean
1408436 fix: factory template formatting (#1110) by @enekochan
b8f8909 minor: change Foundry's baseline (#1108) by @nikophil
May 19th, 2026 - v2.9.2...v2.10.0
withoutDoctrineEvents() is called within flush_after() (#1111) by @nikophilwithoutDoctrineEvents() to suppress listeners during factory create (#1109) by @seb-jean5e70129 fix: arrange compatibility with PHPUnit 10 (#1103) by @nikophil
5e70129 fix: arrange compatibility with PHPUnit 10 (#1103) by @nikophil
February 17th, 2026 - v2.9.1...v2.9.2
47a431c chore(ci): use-dama => no-dama (#1090) by @nikophil d8ce94b fix: ensure in WebTestCase with kernel already boot does not occur (#1088) by @nik
47a431c chore(ci): use-dama => no-dama (#1090) by @nikophil d8ce94b fix: ensure in WebTestCase with kernel already boot does not occur (#1088) by @nikophil 4820f3c chore: fix bug report template by @nikophil 516b786 chore: test using PHPunit 13 (#1086) by @nikophil 692f74c docs: minor docs fixes (#1082) by @nikophil
February 8th, 2026 - v2.9.0...v2.9.1
This release deprecates Factories and ResetDatabase traits in favor of the usage of the PHPUnit extension shipped with Foundry. These features mainly…
This release deprecates Factories and ResetDatabase traits in favor of the usage of the PHPUnit extension shipped with Foundry. These features mainly impact users using PHPUnit >= 10.
You can now remove all usages of the Factories trait. And replace the trait ResetDatabase with the attribute #[ResetDatabase]. Rectors sets are shipped with the release, see https://github.com/zenstruck/foundry/blob/2.x/UPGRADE-2.9.md.
You can even automate the reset database mechanism:
<!-- phpunit.xml -->
<phpunit>
<extensions>
<bootstrap class="Zenstruck\Foundry\PHPUnit\FoundryExtension">
<parameter name="enabled-auto-reset" value="true"/>
</bootstrap>
</extensions>
</phpunit>
This will automatically reset the database before all KernelTestCase tests. With this configuration, even #[ResetDatabase] traits can be omitted.
5e11589 minor: fix last bits before release (#1080) by @nikophil
4f97e89 fix(in-memory): trigger in memory on PreparationStarted (#1077) (#1080) by @nikophil
e539491 fix: handle reset DB mechanism along with "before hooks" methods (#1070) (#1080) by @nikophil
2d59700 feat: automatic DB reset (#1068) (#1080) by @nikophil
9aaf683 minor: remove useless Factories trait (#1067) (#1080) by @nikophil
78b95d1 feat(2.9): deprecate ResetDatabase trait (#985) (#1080) by @nikophil
11b4b03 fix permutations in .github/workflows/phpunit.yml (#1080) by @nikophil
3025311 remove useless import (#1080) by @nikophil
f91c2fa fix: fixes after deprecating Factories trait (#1066) (#1080) by @nikophil
deb7637 feat(2.9): deprecate Factories trait and force PHPUnit extension usage (#968) (#1080) by @nikophil
e57d750 refactor: harmonize how factories are proxified in data providers (#1065) (#1080) by @nikophil
9cbf3c7 minor: some house keeping (#1064) (#1080) by @nikophil
c45e03c fix: allow deleting ghost object (#1076) by @nikophil 86a2036 minor: provide a way to skip faker's seed management (#1075) by @nikophil 32542a
c45e03c fix: allow deleting ghost object (#1076) by @nikophil 86a2036 minor: provide a way to skip faker's seed management (#1075) by @nikophil 32542a6 chore: use APP_ENV=test for benchmark (#1074) by @nikophil 4b6324e minor: add priorities for PHPUnit hooks (#1073) by @nikophil 63c3cac minor: use test environment (#1072) by @nikophil 5dccced Update issue templates (#1064) by @nikophil
February 3rd, 2026 - v2.8.6...v2.8.7
4d81bbe fix: always register "inverseRelationshipCallbacks" even if Foundry is not booted (#1063) by @nikophil f43a735 fix(faker): change how FOUNDRY_
4d81bbe fix: always register "inverseRelationshipCallbacks" even if Foundry is not booted (#1063) by @nikophil f43a735 fix(faker): change how FOUNDRY_FAKER_SEED is read (#1061) by @nikophil
January 20th, 2026 - v2.8.5...v2.8.6
f6e35e5 fix(autorefresh): prevent weird autorefresh recursion (#1060) by @nikophil 377c6d4 fix: handle derived entities in autorefresh mechanism (#105
f6e35e5 fix(autorefresh): prevent weird autorefresh recursion (#1060) by @nikophil 377c6d4 fix: handle derived entities in autorefresh mechanism (#1058) by @nikophil 8701b45 mnior: reboot kernel in database resetter instead of shutdown (#1059) by @nikophil 965fe3c refactor: simplify ResetDatabaseManager (#1054) by @nikophil 473559c chore: add PHP 8.5 to test matrix (#1043) by @nikophil 6c3a127 refactor: explicitly boot Foundry in ResetDatabase (#1049) by @nikophil 368e686 chore: skip legacy proxy tests using #[RequiresMethod] (#1048) by @nikophil d7add25 chore: require symfony/flex as dev dependency (#1047) by @nikophil
January 20th, 2026 - v2.8.4...v2.8.5
45b6e21 fix: remove problematic "conflict" in composer.json (#1046) by @nikophil
45b6e21 fix: remove problematic "conflict" in composer.json (#1046) by @nikophil
December 23rd, 2025 - v2.8.3...v2.8.4
a102c0a fix: Allow PersistManager::refresh() to not throw in specific cases (#1044) by @nikophil d4f9997 fix: auto-refresh problem with doctrine/orm 2
a102c0a fix: Allow PersistManager::refresh() to not throw in specific cases (#1044) by @nikophil d4f9997 fix: auto-refresh problem with doctrine/orm 2 (#1042) by @nikophil cace455 Update issue templates by @nikophil b0a5703 fix: call inverse relatoinship callback before afterInstantiate() (#1041) by @nikophil
December 22nd, 2025 - v2.8.2...v2.8.3
9621dae Improve phpdoc for non empty list (#1037) by @VincentLanglet
9621dae Improve phpdoc for non empty list (#1037) by @VincentLanglet
December 9th, 2025 - v2.8.1...v2.8.2
7b9dc07 chore: actually suport Symfony 8 (#1022) by @nikophil
7b9dc07 chore: actually suport Symfony 8 (#1022) by @nikophil
December 2nd, 2025 - v2.8.0...v2.8.1
This release introduces a new attribute #[AsFoundryHook], which allows to declare Foundry hooks as Symfony services. It also permits to have "global"
This release introduces a new attribute #[AsFoundryHook], which allows to declare Foundry hooks as Symfony services. It also permits to have "global" hooks for all kind of objects created with Foundry:
final class FoundryHook
{
#[AsFoundryHook(Post::class)]
public function beforeInstantiate(BeforeInstantiate $event): void
{
// do something before the post is instantiated:
// $event->parameters is what will be used to instantiate the object, manipulate as required
// $event->objectClass is the class of the object being instantiated
// $event->factory is the factory instance which creates the object
}
#[AsFoundryHook(Post::class)]
public function afterInstantiate(AfterInstantiate $event): void
{
// $event->object is the instantiated Post object
// $event->parameters contains the attributes used to instantiate the object and any extras
// $event->factory is the factory instance which creates the object
}
#[AsFoundryHook(Post::class)]
public function afterPersist(AfterPersist $event): void
{
// this event is only called if the object was persisted
// $event->object is the persisted Post object
// $event->parameters contains the attributes used to instantiate the object and any extras
// $event->factory is the factory instance which creates the object
}
#[AsFoundryHook]
public function afterInstantiateGlobal(AfterInstantiate $event): void
{
// Omitting the class defines a "global" hook which will be called for all objects
}
}
8dc0b1f feat(2.8): introduce #[AsFoundryHook] attribute (#986) by @nikophil
bf4549c feat(2.8): dispatch events (#974) by @nikophil
8516af1 docs: Remove array params on function alwaysForce (#1028) by @philpichet
5f3a6b1 feat: add hooks priority (#1029) by @nikophil
November 9th, 2025 - v2.7.9...v2.8.0
#[AsFoudryHook] attribute (#986) by @nikophil41ab3ae fix: auto-refresh with Mongo after DoctrineMongoDBBundle 5.4.3 (#1030) by @nikophil
41ab3ae fix: auto-refresh with Mongo after DoctrineMongoDBBundle 5.4.3 (#1030) by @nikophil
November 7th, 2025 - v2.7.8...v2.7.9
728c8f8 minor: Add default value to Factory::attributes (#1026) by @VincentLanglet 0fe1017 tests: ensure Doctrine lifecycle works (#1020) by @nikophil
728c8f8 minor: Add default value to Factory::attributes (#1026) by @VincentLanglet 0fe1017 tests: ensure Doctrine lifecycle works (#1020) by @nikophil 1247b0b chore: remove paratest from dev dependencies (#1023) by @nikophil 11355a9 chore: add concurrency for all workflows (#1019) by @nikophil fed6e4a chore: fix rector with bamarni (#1018) by @nikophil 545cf18 chore: split CIs and add concurrency (#1017) by @nikophil 17796f2 chore: add bc-check to CI (#1016) by @nikophil b8ced9b chore: disable sync template for cs config (#1015) by @nikophil b802463 chore: some housekeeping (#1014) by @nikophil
November 5th, 2025 - v2.7.7...v2.7.8
7766a85 fix: only use PersistedObjectsTracker when auto-refresh is enabled (#1013) by @nikophil
7766a85 fix: only use PersistedObjectsTracker when auto-refresh is enabled (#1013) by @nikophil
October 23rd, 2025 - v2.7.6...v2.7.7
95d2a96 fix: autorefresh should work after kernel shutdown (#1011) by @nikophil 0ea8430 tests: ensure OneToMany relationships are refreshed (#1010) by
95d2a96 fix: autorefresh should work after kernel shutdown (#1011) by @nikophil 0ea8430 tests: ensure OneToMany relationships are refreshed (#1010) by @nikophil 3c6faff fix: RepositoryAssertion::exist() $criteria should allow mixed (#1007) by @nikophil 81cc97d minor: accept as story any child of Story (#1006) by @alsciende e99f3b0 chore: run rector CI with PHPUnit 12 (#1002) by @nikophil
October 20th, 2025 - v2.7.5...v2.7.6
81eacf5 docs: add a note about using make:factory --test (#1000) by @ttskch 660942d [Rector] Add rector to require-dev and use single autoload vendor
81eacf5 docs: add a note about using make:factory --test (#1000) by @ttskch
660942d [Rector] Add rector to require-dev and use single autoload vendor for run PHPUnit (#1001) by @samsonasik
f06d58d fix: using refresh_all() with flush_after() (#999) by @HypeMC
October 10th, 2025 - v2.7.4...v2.7.5
make:factory --test (#1000) by @ttskchrefresh_all() with flush_after() (#999) by @HypeMC9489e83 fix: 🐛 use isser instead of constructor to apply autorefresh setting to Factory (#998) by @ttskch
9489e83 fix: 🐛 use isser instead of constructor to apply autorefresh setting to Factory (#998) by @ttskch
October 8th, 2025 - v2.7.3...v2.7.4
45214f7 fix: revert adding PersistManager::findBy() (#996) by @nikophil b36b9b3 chore: upgrade PHPStan (#997) by @nikophil 55f2689 fix: edge case with
45214f7 fix: revert adding PersistManager::findBy() (#996) by @nikophil b36b9b3 chore: upgrade PHPStan (#997) by @nikophil 55f2689 fix: edge case with Doctrine Middleware & early kernel boot (#993) by @HypeMC 9fa21b3 fix(repository): use IN() when an array is passed (#995) by @nikophil cad1466 fix: handle readonly when refreshing from repository decorator (#989) by @nikophil b4b2ffe fix: Enhanced random method with additional safety check. (#991) by @sofwar
October 5th, 2025 - v2.7.2...v2.7.3
97b60b6 fix: applyStateMethod should not be internal (#988) by @nikophil
97b60b6 fix: applyStateMethod should not be internal (#988) by @nikophil
September 25th, 2025 - v2.7.1...v2.7.2
90866d2 fix(autorefresh): return fresh data from RepositoryDecorator methods (#983) by @nikophil 485746e fix(autorefresh): don't use clone to get the
90866d2 fix(autorefresh): return fresh data from RepositoryDecorator methods (#983) by @nikophil 485746e fix(autorefresh): don't use clone to get the id values (#980) by @nikophil 21b659b chore: fix issue template (#982) by @nikophil 5d02ac6 Fix link to UPGRADE-2.7.md file (#978) by @Kocal
September 24th, 2025 - v2.7.0...v2.7.1
This release deprecates the proxy system in PHP 8.4 in favor of an auto-refresh mechanism which leverages PHP lazy objects.
This release deprecates the proxy system in PHP 8.4 in favor of an auto-refresh mechanism which leverages PHP lazy objects.
Please follow the upgrade guide.
cd1b31a docs: add "Troubleshooting" section in upgrade guide (#943) by @nikophil a83c249 feat: enable auto-refresh at factory level (#970) by @nikophil 32e9868 fix: few fixes after #972 (#943) by @nikophil 47b0d79 feat: use ghost objects for auto refresh mechanism (#967) (#943) by @nikophil 3a131ef minor: improve deprecation message (#943) by @nikophil 30df79d feat: auto-refresh objects from RepositoryDecorator (#943) by @nikophil f675c37 minor: use ProxyGenerator::unwrap() instead of unproxy() and prevent deprec (#943) by @nikophil 9d04094 minor: remove PersistedObjectsTracker::reset() call in tear down (#943) by @nikophil 3e23fda refactor(maker): deprecate --with-phpdocs for PHP >=8.4 (#952) (#943) by @nikophil 61cabac docs: create upgrade guide to 2.7 and document auto-refresh (#951) (#943) by @nikophil fe6374b feat: auto refresh with lazy object php84 enabled by config (#950) (#943) by @nikophil 9717676 feat: Rector rules to help migrating away from proxy (#941) (#943) by @nikophil 35e8da6 feat: use native proxies for object creation in data providers (#943) by @nikophil 02f85f2 feat: create proxy system with PHP 8.4 lazy proxies (#943) by @nikophil
…(#962) by @BackEndTea f9e95cb fix: doctrine deprecation (#961) by @nikophil c8256e3 Add support for Symfony 8 (#960) by @Kocal
67a7731 fix: misc fixes when creating objects in data provider (#972) by @nikophil 5e068c4 fix: ignore PHPUnit warnings when dataprovider returns more data than test method accepts (#958) by @nikophil 0a65872 Fix proxying of classes that have tenative return types (#962) by @BackEndTea f9e95cb fix: doctrine deprecation (#961) by @nikophil c8256e3 Add support for Symfony 8 (#960) by @Kocal
August 28th, 2025 - v2.6.2...v2.6.3
6f4e920 fix(proxy): add autorefresh call for union and intersection return types (#959) by @BackEndTea 58fd89a feat: introduce method FactoryCollectio
6f4e920 fix(proxy): add autorefresh call for union and intersection return types (#959) by @BackEndTea 58fd89a feat: introduce method FactoryCollection::applyStateMethod() (#956) by @nikophil
August 5th, 2025 - v2.6.1...v2.6.2
…(#945) by @treztreiz e5e5162 fix: doctrine deprecation (#949) by @nikophil dc54221 Update index.rst (#946) by @treztreiz 5ae21ec docs: fix forceSet()…
932c63a feat: rename foundry:load-stories to foundry:load-fixtures (#954) by @kbond
1d31275 Update index.rst (#945) by @treztreiz
e5e5162 fix: doctrine deprecation (#949) by @nikophil
dc54221 Update index.rst (#946) by @treztreiz
5ae21ec docs: fix forceSet() to _set() in example (#948) by @mariecharles, Marie CHARLES
56161cc feat: add randomRangeOrCreate() method (#932) by @elliotbruneel, Elliot Bruneel
2d28e67 test: ensure no deprecation when Factories used in parent class (#922) by @nikophil
b25eb60 minor: fix running phpunit w/o arguments (#933) by @kbond
f9b8132 minor: add UID types to factory maker (#936) by @HypeMC
030f7aa chore: temporarily disable cascade relationship combinations (#938) by @nikophil
7e434ff feat: minor improvements to foundry:load-stories (#930) by @nikophil bd50a86 merge 2.5.x into 2.x (#931) by @nikophil 159d700 doc: adjust flow
7e434ff feat: minor improvements to foundry:load-stories (#930) by @nikophil
bd50a86 merge 2.5.x into 2.x (#931) by @nikophil
159d700 doc: adjust flow (#923) by @kbond
ca95279 feat: Introduce #[AsFixture] attribute and foundry:load-fixture command (#903) by @nikophil
June 5th, 2025 - v2.5.4...v2.6.0
#[AsFixture] attribute and foundry:load-fixture command (#903) by @nikophil8238e0f fix: remove useless Configuration::boted() check (#929) by @nikophil
8238e0f fix: remove useless Configuration::boted() check (#929) by @nikophil
June 4th, 2025 - v2.5.4...v2.5.5
8e202b4 fix: TypeError FactoryCollection::create() when calling many with 0 (#925) by @jdecool
8e202b4 fix: TypeError FactoryCollection::create() when calling many with 0 (#925) by @jdecool
May 31st, 2025 - v2.5.3...v2.5.4
FactoryCollection::create() when calling many with 0 (#925) by @jdecool01c5ce3 fix: should not use flush_after() in FactoryCollection::create() (#908) by @nikophil 7545b2f docs: Fix LazyValue namespace (#919) by @odolbeau
01c5ce3 fix: should not use flush_after() in FactoryCollection::create() (#908) by @nikophil
7545b2f docs: Fix LazyValue namespace (#919) by @odolbeau
ccc309b docs: fix quote (#918) by @nikophil
f0ae498 docs: Fix save() -> _save() in documentation (#917) by @smnandre
May 30th, 2025 - v2.5.2...v2.5.3
save() -> _save() in documentation (#917) by @smnandre40ce8a2 fix: reuse should work with all kind of relationships (#915) by @nikophil f6c81a0 fix: can use reuse with inheritance (#914) by @nikophil
40ce8a2 fix: reuse should work with all kind of relationships (#915) by @nikophil f6c81a0 fix: can use reuse with inheritance (#914) by @nikophil
May 26th, 2025 - v2.5.1...v2.5.2
fe12d09 fix: add missing flush_once feature flag (#912) by @phasdev f991999 docs: Fix data providers phpunit link (#906) by @alexander-schranz 19ddd55
fe12d09 fix: add missing flush_once feature flag (#912) by @phasdev f991999 docs: Fix data providers phpunit link (#906) by @alexander-schranz 19ddd55 docs: in memory behavior needs PhpUnit extension (#905) by @nikophil 6a0b4ac docs: improve docs for in-memory repositories (#904) by @nikophil
May 22nd, 2025 - v2.5.0...v2.5.1
…bundle (#882) by @nikophil a54d97e minor: ignore deprecations related to ProxyHelper::generateLazyProxy() by @nikophil df4d355 chore: misc DX and test…
30270ec feat: introduce "in-memory" behavior (#590) by @nikophil
Foundry now allows to use "in-memory" repositories in your factories. This is mainly useful for DDD applications or with hexagonal architecture, where repositories in the domain are usually interfaces for which main implementations are a Doctrine one. You can tell Foundry to use the "in-memory" version of these repositories.
See docs
5b027c0 feat: flush once (#873) by @nikophil
Foundry used to call ObjectManager::flush() for every entity (or ODM document) created. This could have a performance downside. Since 2.5, Foundry is able to only call flush() once per call of PersistentObjectFactory::create() in userland.
See docs
7b6f70c feat: enable flush once with config (#885) by @nikophil
87acf7a feat: add generic doctrine-like repository for in-memory (#887) by @nikophil
ae662a3 minor: make "in-memory" classes experimental (#895) by @nikophil
0b09c20 chore: decouple from framework bundle (#882) by @nikophil
a54d97e minor: ignore deprecations related to ProxyHelper::generateLazyProxy() by @nikophil
df4d355 chore: misc DX and testsuite improvements (#881) by @nikophil
a19ce4c tests: add ZenstruckFoundryBundleTest (#878) by @silasjoisten, @nikophil
May 13th, 2025 - v2.4.3...v2.5.0
ZenstruckFoundryBundleTest (#878) (#901) by @silasjoisten, @nikophil2b31429 chore: test with SF7.3 (#891) by @nikophil 50350cb minor: allow 10% gap in benchmark workflow (#880) by @nikophil
2b31429 chore: test with SF7.3 (#891) by @nikophil 50350cb minor: allow 10% gap in benchmark workflow (#880) by @nikophil
May 5th, 2025 - v2.4.2...v2.4.3
25e9125 fix: Prevent random value collisions when kernel is rebooted (#879) by @HypeMC
25e9125 fix: Prevent random value collisions when kernel is rebooted (#879) by @HypeMC
April 17th, 2025 - v2.4.1...v2.4.2
6b4fea8 fix(faker): missing parameter when using custom faker service (#877) by @silasjoisten
6b4fea8 fix(faker): missing parameter when using custom faker service (#877) by @silasjoisten
April 15th, 2025 - v2.4.0...v2.4.1
faker service (#877) by @silasjoisten…due to csfix (#829) by @nikophil 7b33216 minor: deprecate auto-persist (#818) by @nikophil eb6e983 feat(faker): Improve reproducibility with faker (#8…
distribute() method by @nikophil in https://github.com/zenstruck/foundry/pull/826If you have a collection of values that you want to distribute over a collection, you can use the distribute() method:
// let's say we have 2 categories...
$categories = CategoryFactory::createSequence(
[
['name' => 'category 1'],
['name' => 'category 2'],
]
);
// ...that we want to "distribute" over 2 posts
$posts = PostFactory::new()
->sequence(
[
['name' => 'post 1'],
['name' => 'post 2'],
]
)
// "post 1" will have "category 1" and "post 2" will have "category 2"
->distribute('category', $categories)
// you can even chain "distribute()" methods:
// first post is published today, second post is published tomorrow
->distribute('publishedAt', [new \DateTimeImmutable('today'), new \DateTimeImmutable('tomorrow')])
->create();
When creating nested objects, sometimes it can be useful to tell Foundry to always use the same object for a given class. It can enforce coherence in your fixtures and avoid creating too many objects.
In order to do this, you can use the reuse() method: it will force Foundry to use the object passed as parameter in all ManyToOne and OneToOne relationships using the class of this object:
// let's say both Post and Comment classes have a ManyToOne field "author" of class User
$user = UserFactory::createOne();
PostFactory::new([
'comments' => CommentFactory::new()->many(5),
])
// by calling reuse, the post and all its comments will have the same author
->reuse($user)
->create();
Reproducibility with faker is improved: now, all test run will use a random seed (by default, it used to be passed null), and if you're using Foundry's extension for PHPUnit, this seed will be displayed at the end of the tests.
You can also freeze the seed by using the environment variable FOUNDRY_FAKER_SEED
➜ FOUNDRY_FAKER_SEED=1234 vendor/bin/phpunit
................................... 35 / 35 (100%)
Faker seed: 1234
Time: 00:00.047, Memory: 48.50 MB
You can now disable the "beginner" hints which are generated by the make:factory command:
# config/packages/zenstruck_foundry.yaml
zenstruck_foundry:
make_factory:
add_hints: false
force() helper (#854) by @nikophilFoundry already allows you to "force" a property globally to a factory. Now with the force() helper, you can force it at a single place:
use App\Factory\PostFactory;
use function Zenstruck\Foundry\force;
// in this case, the "body" attribute will be set directly, without using the setter
PostFactory::createOne(['body' => force('some body')]) ;
// in this case, the "title" attribute will still be used in the constructor (otherwise an error would be thrown)
PostFactory::createOne(['title' => force('some title')]) ;
// ...unless we disable the constructor:
PostFactory::new()
->instantiateWith(Instantiator::withoutConstructor())
->create(['title' => force('some title')]) ;
659a7bc minor: use mt_rand instead of random_int (#869) by @kbond
348b28d docs: fix default_namespace (#872) by @ebedy
92d9f28 chore(phpbench): actually run phpbench with a baseline (#868) by @nikophil
1a829e5 feat: optimize performance of repository::random() (#867) by @mdeboer
5ccbe51 feat: add support for benchmarks using phpbench (#866) by @mdeboer, @nikophil
2df354c fix: performance problem with reuse (#865) by @nikophil
0747e04 docs: document Faker reproducibility (#860) by @nikophil
f8cc3a0 fix: handle empty constructors (#859) by @nikophil
cb63756 chore: merge 2.3.x (#858) by @nikophil, @mdeboer, @Chris53897
b1e7aec feat(maker): allow no hints (#857) by @nikophil
59d617c fixes typo (#850) by @mvhirsch
5cc8575 feat: introduce "reuse()" method (#804) by @nikophil, @kbond
21f32b8 docs: fix wrong class name (#846) by @nikophil
48d9249 docs: minor fixes (#837) by @nikophil
bdda45c doc: fixes linking to object-proxy (#825) by @mvhirsch
719710a test: ensure Proxy::_real() always return same object (#809) by @nikophil
d15de0e feat: introduce distribute() method (#826) by @nikophil
5647b5c fix: prevent infinite loop when ->create() is called in after persist callback (#832) by @nikophil
6e1d726 fix: fix failing faker test due to csfix (#829) by @nikophil
7b33216 minor: deprecate auto-persist (#818) by @nikophil
eb6e983 feat(faker): Improve reproducibility with faker (#807) by @nikophil
ae96d19 chore: use PHPUnit 12 (#810) by @nikophil
413bb10 chore: upgrade phpstan (#828) by @nikophil
fbf0981 fix: actually disable persistence cascade (#817) by @nikophil
2426f3e fix: trigger after persist callbacks for entities scheduled for insert (#822) by @nikophil
dea6246 fix(doc): update yml config file for reset keys (#819) by @asalisaf
da1e9db docs: Make sure we add links on separate lines(#823) by @Nyholm
ad8d72c fix: can index one to many relationships based on "indexBy" (#815) by @nikophil
f76cba2 fix: fix deprecation message for Factories trait (#806) by @nikophil
207562f fix: remove APP_ENV from .env (#803) by @nikophil
9032c38 feat: skip readonly properties on entities when generating factories (#798) by @KDederichs, @nikophil
April 14th, 2025 - v2.3.2...v2.4.0
mt_rand instead of random_int (#869) by @kbond#[AsFoundryHook] / global event system (#871) by @nikophildistribute() method (#826) by @nikophile5c6973 fix: handle "inverse one to one" without "placeholder" solution (#855) by @nikophil
e5c6973 fix: handle "inverse one to one" without "placeholder" solution (#855) by @nikophil
March 31st, 2025 - v2.3.9...v2.3.10
b23f1d3 feat: add force() helper (#854) by @nikophil bf731cb chore: add support for doctrine/persistence 4 (#852) by @Chris53897
b23f1d3 feat: add force() helper (#854) by @nikophil bf731cb chore: add support for doctrine/persistence 4 (#852) by @Chris53897
8356b53 fix: fix doctrine collection with union/intersection type (#847) by @mdeboer, @nikophil 6d0d7cf fix: bug with factory collectin of persistent
8356b53 fix: fix doctrine collection with union/intersection type (#847) by @mdeboer, @nikophil 6d0d7cf fix: bug with factory collectin of persistent factory in unit test (#842) by @nikophil
2f523df fix: use Doctrine metadata event when persist is disabled (#841) by @nikophil c28b9d7 minor: add parameter "withAutoRefresh" to unproxy() func
2f523df fix: use Doctrine metadata event when persist is disabled (#841) by @nikophil c28b9d7 minor: add parameter "withAutoRefresh" to unproxy() function (#840) by @nikophil 6edd8c2 chore: upgrade also dama when upgrading phpunit version (#839) by @nikophil
300645b fix: can call ->create() in after persist callback (#833) by @nikophil
300645b fix: can call ->create() in after persist callback (#833) by @nikophil
February 25th, 2025 - v2.3.5...v2.3.6
fbf0981 fix: actually disable persistence cascade (#817) by @nikophil 2426f3e fix: trigger after persist callbacks for entities scheduled for insert (
fbf0981 fix: actually disable persistence cascade (#817) by @nikophil 2426f3e fix: trigger after persist callbacks for entities scheduled for insert (#822) by @nikophil
February 24th, 2025 - v2.3.4...v2.3.5
ad8d72c fix: can index one to many relationships based on "indexBy" (#815) by @nikophil
ad8d72c fix: can index one to many relationships based on "indexBy" (#815) by @nikophil
February 14th, 2025 - v2.3.3...v2.3.4
f76cba2 fix: fix deprecation message for Factories trait (#806) by @nikophil
f76cba2 fix: fix deprecation message for Factories trait (#806) by @nikophil
…persisted (#781) by @nikophil 54c7424 feat: deprecate when Factories trait is not used in a KernelTestCase (#766) by @nikophil 9937b11 chore: add issu…
46464cc chore(ci): misc improvments in CI permutations (#797) by @nikophil
86c5aab test: assert updates are implicitly persisted (#781) by @nikophil
54c7424 feat: deprecate when Factories trait is not used in a KernelTestCase (#766) by @nikophil
9937b11 chore: add issue template (#795) by @nikophil
884113f fix: simplify reset database extension (#779) by @nikophil
bd50f41 fix: add unpersisted object to relation (#780) by @nikophil
17388bc tests: transform "migrate" testsuite into "reset database" testsuite (#763) by @nikophil
e45913e fix: propagate "schedule for insert" to factory collection (#775) by @nikophil
d9262cc fix: fix .gitattributes and #[RequiresPhpUnit] versions (#792) by @nikophil
57c42bc tests: fix a test after a bug was resolved in doctrine migrations (#791) by @nikophil
200cfdd [Doc] Fix misc issues (#789) by @javiereguiluz
553807b minor: add platform config to mysql docker container (#788) by @kbond
316d3c7 doc: fix typo (#782) by @norival
0d66c02 minor: use refresh for detached entities (#778) by @nikophil
29b48a1 test: add orphan removal premutation (#777) by @nikophil
c00b3f1 fix: isPersisted must work when id is known in advance (#774) by @nikophil
f303f3f fix: remove _refresh call from create object process (#773) by @nikophil
65cedbf fix: use a "placeholder" for inversed one-to-one (#755) by @nikophil
5f99506 minor: introduce PerssitenceManager::isPersisted() (#754) by @nikophil
9948d6a fix(ci): change PHP version used by PHP CS-Fixer (#768) by @nikophil
cf3cc8b docs: Minor syntax fix (#767) by @javiereguiluz
e8f9a92 docs: clarify default attributes and fixed some syntax issues (#765) by @nikophil, @javiereguiluz
1db5ced tests: validate PSR-4 in CI (#762) by @nikophil
cafc693 [Docs fix] Just spelling in docs (#761) by @GrinWay
d192c4a [Docs fix] Proxy::_save() instead of Proxy::save() (#760) by @GrinWay
ff7210a [Docs fix] Factory::_real() instead Factory::object() (#759) by @GrinWay
d1240b1 fix: RequiresPhpunit should use semver constraint by @nikophil
fd2e38c chore: upgrade to phpstan 2 (#748) by @nikophil
23b4ec4 tests: automatically create cascade persist permutations (#666) by @nikophil
f4ba5d8 tests: add CI permutation with windows (#747) by @nikophil
c17ef91 fix: define FactoryCollection type more precisely (#744) by @nikophil
98f018c feat: schedule objects for insert right after instantiation (#742) by @nikophil
2dcad10 feat: provide current factory to hook (#738) by @nikophil
ea89504 fix: pass to afterPersist hook the attributes from beforeInstantiate (#745) by @nikophil, @kbond
One column per quarter.