Context
Following recent discussions with @nikophil , I'd like to open this issue to gather feedback on integrating xefi/faker-php into Foundry as an optional alternative to fakerphp/faker.
We agreed that we should probably let users choose between the two implementations. This would probably be in Foundry 3, switchable via configuration.
@GautierDele and I maintain xefi/faker-php and are happy to do the integration work. This issue is mostly about aligning on the approach (and on the two open questions below) before we start.
About xefi/faker-php
xefi/faker-php is an actively maintained, modular reimplementation of Faker for PHP 8.3+ (MIT).
$faker = new Xefi\Faker\Faker();
$faker->name(); // John Doe
$faker->iban(); // PX41711762752955497163783543
Unlike fakerphp/faker, it ships a small core and moves providers and locales into dedicated, opt-in extension packages (e.g. xefi/faker-php-images, xefi/faker-php-files, xefi/faker-php-currencies, and per-locale packages such as xefi/faker-php-locales-en-us).
Proposed action items
Pending validation from the Foundry team, we're happy to own the following:
- Deprecation layer : a dedicated bridge package mapping legacy methods to their new counterparts. Both implementations could then run in parallel, keeping breaking changes to a minimum while guiding users toward the new API through deprecation notices.
- Dual-Faker support in Foundry : support both
fakerphp/faker and xefi/faker-php on the Foundry side, selectable through a configuration option, so teams can migrate at their own pace.
- Locale coverage :
xefi/faker-php currently covers fewer locales than fakerphp/faker (locales are opt-in packages). If locale coverage turns out to be a blocker, could you let us know which specific locales are critical for Foundry users, so we can prioritize implementing them?
- Seeding compatibility : verify that Foundry's seeding mechanism integrates cleanly with
xefi/faker-php's seeding system, so reproducible data generation and seed-based workflows keep working after a migration.
- Rector rules : Maybe we can create a rule set to automate migration from the old Faker method calls to the new ones, so end users can migrate with minimal manual work. But if we ensure point 4, it should be useless to create Rector rules.
Open questions
Two design points I'd like the team's input :
1. Single entry point vs. explicit autocompletion
In a factory, the current entry point is self::faker(), which returns a Faker\Generator. With xefi/faker-php it would return a Xefi\Faker\Faker instance instead. I'd really like to keep a single entry point, but I can't see how to make autocompletion explicit about which implementation is returned without introducing a second method (e.g. self::theNewFaker()). Has anyone got a cleaner idea here?
2. Dependency management during the v2 → v3 transition
In Foundry 3, we expect the hard dependency on fakerphp/faker in composer.json to be dropped. That means the last Foundry 2 releases will need a way to make users explicitly require-dev one of the two libraries. What's the cleanest approach for you ? A Composer conflict/replace trick, a runtime check with a helpful error pointing users to install one of the two libs, docs-only guidance, or something else?
Keen to hear the team's thoughts on the overall direction and on the two open questions above. Once we've agreed on an approach, we're ready to start with a prototype / draft PR.
Context
Following recent discussions with @nikophil , I'd like to open this issue to gather feedback on integrating
xefi/faker-phpinto Foundry as an optional alternative tofakerphp/faker.We agreed that we should probably let users choose between the two implementations. This would probably be in Foundry 3, switchable via configuration.
@GautierDele and I maintain
xefi/faker-phpand are happy to do the integration work. This issue is mostly about aligning on the approach (and on the two open questions below) before we start.About
xefi/faker-phpxefi/faker-phpis an actively maintained, modular reimplementation of Faker for PHP 8.3+ (MIT).Unlike
fakerphp/faker, it ships a small core and moves providers and locales into dedicated, opt-in extension packages (e.g.xefi/faker-php-images,xefi/faker-php-files,xefi/faker-php-currencies, and per-locale packages such asxefi/faker-php-locales-en-us).Proposed action items
Pending validation from the Foundry team, we're happy to own the following:
fakerphp/fakerandxefi/faker-phpon the Foundry side, selectable through a configuration option, so teams can migrate at their own pace.xefi/faker-phpcurrently covers fewer locales thanfakerphp/faker(locales are opt-in packages). If locale coverage turns out to be a blocker, could you let us know which specific locales are critical for Foundry users, so we can prioritize implementing them?xefi/faker-php's seeding system, so reproducible data generation and seed-based workflows keep working after a migration.Open questions
Two design points I'd like the team's input :
1. Single entry point vs. explicit autocompletion
In a factory, the current entry point is
self::faker(), which returns aFaker\Generator. Withxefi/faker-phpit would return aXefi\Faker\Fakerinstance instead. I'd really like to keep a single entry point, but I can't see how to make autocompletion explicit about which implementation is returned without introducing a second method (e.g.self::theNewFaker()). Has anyone got a cleaner idea here?2. Dependency management during the v2 → v3 transition
In Foundry 3, we expect the hard dependency on
fakerphp/fakerincomposer.jsonto be dropped. That means the last Foundry 2 releases will need a way to make users explicitlyrequire-devone of the two libraries. What's the cleanest approach for you ? A Composerconflict/replacetrick, a runtime check with a helpful error pointing users to install one of the two libs, docs-only guidance, or something else?Keen to hear the team's thoughts on the overall direction and on the two open questions above. Once we've agreed on an approach, we're ready to start with a prototype / draft PR.