Note: This is a maintained fork of the original CakePHPFixtureFactories.
Main differences:
- Supports multiple generators via adapters (chose your generator library).
- Modern configurable generator type guessing per field name/type when baking.
If you're upgrading from vierge-noire/cakephp-fixture-factories:^3.0, the main breaking change is the generator type.
Callbacks in setDefaultTemplate() now receive GeneratorInterface instead of Faker\Generator:
- use Faker\Generator;
+ use CakephpFixtureFactories\Generator\GeneratorInterface;
protected function setDefaultTemplate(): void
{
- $this->setDefaultData(function (Generator $faker) {
+ $this->setDefaultData(function (GeneratorInterface $generator) {
return [
- 'email' => $faker->email,
+ 'email' => $generator->email(),
];
});
}Key changes:
- Replace
Faker\Generatortype hints withGeneratorInterface - Use
$this->getGenerator()instead of deprecated$this->getFaker() - Prefer method calls
->email()over property access->email(both work)
See Generator Differences for details on the abstraction layer.
ArticleFactory::make(5)
->with('Authors[3].Address.City.Country')
->persist();composer require --dev dereuromark/cakephp-fixture-factories
CakeFest 2021 - IPC-Berlin 2020 - CakeFest 2020
Send PRs or tickets in GitHub.
Previously, Juan Pablo Ramirez and Nicolas Masson. This fork is maintained by Mark Scherer (dereuromark)
The CakePHPFixtureFactories plugin is offered under an MIT license.
Copyright 2023 Juan Pablo Ramirez and Nicolas Masson
Licensed under The MIT License Redistributions of files must retain the above copyright notice.