Getting Started
Integrations
Integrations on Xefi Faker PHP
Laravel
Faker PHP integrates fully with Laravel, first you need to require the compatibility package:
composer require --dev xefi/faker-php-laravel
After that, faker is ready to use with the faker helper:
namespace Database\Factories;
 
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Str;
 
/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
 */
class UserFactory extends Factory
{
    /**
     * The current password being used by the factory.
     */
    protected static ?string $password;
 
    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition(): array
    {
        return [
            'name' => faker()->name(),
            'email' => faker()->unique()->email(),
        ];
    }
}
Symfony
Faker PHP integrates fully with Symfony, first you need to require the compatibility package:
composer require --dev xefi/faker-php-symfony
After that, Faker is ready to use with the Faker service:
namespace App\DataFixtures;
use App\Entity\User;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
use Xefi\Faker\Faker;
class AppFixtures extends Fixture
{
    public function __construct(private Faker $faker) {}
    public function load(ObjectManager $manager): void
    {
        $user = new User();
        $user->setName($this->faker->name())
             ->setEmail($this->faker->email());
        $manager->persist($user);
        $manager->flush();
    }
}
If you want to specify the locale to use : simply create a config/packages/xefi_faker.yaml file and fill it like this (where fr_FRis your locale) :
xefi_faker_symfony:
  locale: fr_FR