Localize Laravel 5.2 Factory Faker Seeder

Not happy with the default en_US locale used by fzaninotto's PHP Faker Library and subsequently Laravel's Factory Seeder? Neither was I.

Here are two solutions depending on your use case.

Solution 1 - AppServiceProvider.php

use Faker\Generator as FakerGenerator;  
use Faker\Factory as FakerFactory;

...

function register( ) {  
    $this->app->singleton(FakerGenerator::class, function () {
        return FakerFactory::create('en_GB');
    });
}

...

Solution 2

$faker = Faker\Factory::create('fr_FR');

$factory->define(App\User::class, function () use ($faker) {
    return [
        'name' => $faker->name,
        'email' => $faker->email,
        'password' => bcrypt(str_random(10)),
        'remember_token' => str_random(10),
    ];
});

A complete locale list can be found on Github, alternatively you can create your own provider.