Skip to content

2.0.0

Latest

Choose a tag to compare

@dereuromark dereuromark released this 28 May 14:07
4ad0d6a

Tip

First time on v2? See What's new in v2 for a single-page tour of the new surface.

First stable of the v2 line. Per-prerelease notes (linked below) carry the full fix-by-fix detail.

Highlights

  • Immutable factory API: new(), from(), count(), build()/buildMany(), save()/saveMany(), with a read/query split via query() and table().
  • Directional association DSL for() / has(), with alias-explicit overloads (->for($f, 'BusinessAddress')) to disambiguate same-target associations.
  • withRequiredParents() composes exactly the NOT NULL belongsTo parents a schema requires, with requiredParentAssociations() / excludedRequiredParentAssociations() hooks for fine control.
  • recycle($entity) reuses a built parent wherever a belongsTo in the build graph targets its source table — closing the silent N× duplicate-parent footgun.
  • Sequence context object passed to sequence() callables (index, position, total, isFirst, isLast, factory, generator); plus the lighter sequenceField() for varying a single field across rows.
  • TableAssertionsTraitassertTableHas/Missing/Count/Empty, assertEntityExists/Missing over Factory::query() with sharp failure messages.
  • Story scenario abstract with named entity pools (addToPool, getPool, getRandom, getRandomSet), backwards-compatible with existing FixtureScenarioInterface.
  • state() / named states and afterBuild() / afterSave() lifecycle hooks; has() now carries pivot data onto the join row.
  • strictDefinition detector deprecates FK columns set in definition() (names column, alias, migration path); opt-out via Configure mid-migration.
  • Eager FactoryTransactionStrategy by default for leak-safe mixed Factory/direct-save tests, with LazyFactoryTransactionStrategy / LazyTransactionTrait opt-outs.
  • Improved Bake output for the v2 API; bundled Rector ruleset for mechanical 1.x call-site upgrades.

Breaking changes (from 1.x)

  • 1.x deprecated wrappers removed. Migrate to latest 1.x first, then to 2.x — use the bundled rector.php.
  • API renames: make()new(), makeMany()count() + buildMany()/saveMany(), makeFrom()from(), persist()/persistEntities()save()/saveMany(), Factory::get()Factory::table()->get(), Factory::find()Factory::query().
  • Generator property access → method access ($generator->name$generator->name()); Rector-rewritten.
  • enumElement() removed — use enumCase() / enumValue() (no Rector rewrite).
  • FactoryTransactionStrategy now eager by default (1.x was lazy): opens a transaction on the primary test connection. Opt into lazy via LazyFactoryTransactionStrategy / LazyTransactionTrait.

Since 2.0.0-rc.4

  • Fix strictDefinition exempting shared-primary-key 1:1 belongsTo FKs (child id that is both PK and FK escaped the deprecation) (#108).
  • Friendlier requiredParentAssociations() hook errors for unknown and non-belongsTo aliases (#109).

Prerelease detail

rc.4 · rc.3 · rc.2 · rc.1 · beta.3 · beta.2 · beta.1

Full Changelog: 1.4.3...2.0.0