fakerphp/faker
Faker is a PHP library for generating realistic fake data to seed databases, build test fixtures, stress test apps, create sample documents, or anonymize production data. Create a generator with Faker\Factory::create() and call methods like name(), email(), text().
composer require fakerphp/faker — no additional setup required.Faker\Factory::create() (optionally with locale, e.g. create('fr_FR')) and call methods like $faker->name(), $faker->email(), $faker->text() — each invocation yields new random values.DatabaseSeeder) or unit test fixtures (e.g., populating Eloquent models with Factory classes).Faker\Provider\Base and register with $faker->addProvider(new MyCustomProvider($faker)). Use method names that map to real data types (e.g., vatNumber(), companyId()).fr_FR for French addresses, ja_JP for Japanese names). Check Faker\Provider\{Locale}\{Provider} classes for available formats.unique() to ensure no duplicates in a session: $faker->unique()->email(), or regexify() to generate structured values like 'ORD-' . $faker->regexify('[A-Z]{3}\d{5}').UserFactory), use $this->faker directly — Faker is pre-instantiated and injected by Laravel’s test framework.@method annotations on Generator.$faker->name, $faker->city) throws deprecation warnings in v2+ — always use method calls ($faker->name()).randomElements() Behavior Change: In v1.20+, calling randomElements() without a count argument returns 1–3 elements randomly, not all elements — specify count explicitly if needed.Factory::create() defaults to en_US; missing locale-specific data may fall back to base provider (e.g., address() might be generic even for other locales). Verify with $faker->locale.Faker\Generator directly unless building reusable packages.Faker\Generator::setReplay() to fix data for repeatable tests (though seed() is simpler for most unit tests: $faker->seed(1234)).$faker->realText) needs automated migration — run rector process src/ --config vendor/fakerphp/faker/rector-migrate.php.How can I help you explore Laravel packages today?