apie/core), this integrates seamlessly. For non-Apie projects, the value is limited unless the team adopts Apie’s DDD abstractions.FakerPHP as a dependency, making adoption straightforward. No Laravel-specific dependencies (e.g., no Eloquent or Blade hooks).apie-lib-monorepo), which could complicate updates if the monorepo evolves independently. Risk of breaking changes if Apie’s core refactors.ApieClassFaker, allowing teams to extend functionality without modifying the package.User with Address, Address with PostalCode) could introduce memory/CPU overhead in large-scale tests. Profile before heavy use.createModel(), factory()). May require custom bridges for seamless integration with Laravel’s ecosystem.string instead of LastName) won’t benefit.FakeMethod attribute suffice, or is a full ApieClassFaker needed?DatabaseMigrations, RefreshDatabase) may need custom adapters.User with nested Order objects).tinker with fake data).Mockery).ApieObjectFaker in a non-production branch.User field: update factory vs. extend ApieClassFaker).fakeClass() for domain objects.FakeMethod or custom fakers.ApieObjectFaker for consistency with Model::factory() syntax.EntityInterface, ValueObjectInterface).#[FakeMethod], so PHP 8.0+ with experimental attributes enabled (or PHP 8.1+).composer require apie/faker fakerphp/faker
// In a test setup file (e.g., TestCase)
protected function getFaker(): Faker\Generator {
$faker = Factory::create();
$faker->addProvider(ApieObjectFaker::createWithDefaultFakers($faker));
return $faker;
}
$user = $this->getFaker()->fakeClass(User::class);
FakeMethod to ValueObjects or implement ApieClassFaker for edge cases.static properties in fakers).User failed" vs. "fake PostalCode failed").ApieObjectFaker for complex objects but fall back to traditional factories for simple cases.User → Address → PostalCode → Country) could bloat memory usage in parallel tests. Mitigate with:
FakeMethod, ApieClassFaker). Document patterns (e.g., "always use FakeMethod for simple VOs").| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Apie core breaking change | Faker breaks if interfaces change | Pin Apie version in composer.json |
| Circular reference in objects | Infinite recursion crash | Add cycle detection in ApieObjectFaker |
Invalid fake data (e.g., PostalCode regex fails) |
Tests pass but prod fails | Validate faked data in tests (e.g., assertInstanceOf(ValidPostalCode::class)) |
| Custom faker bugs | Synthetic data is incorrect | Unit test each ApieClassFaker |
| PHP version incompatibility | Attributes/enums fail | Use PHP 8.1+ and enable attributes |
How can I help you explore Laravel packages today?