astersnake/faker-chile
Faker Chile adds Chilean fake data to Faker, including RUTs, names, addresses, regions, communes, phone numbers, and companies. Useful for seeding Laravel apps and testing with realistic local records.
astersnake/faker-chile extends Faker with Chilean locale data (RUT, names, addresses, communes/regions, phone numbers). Version 1.0.4 is the first release worth targeting in a modern stack: it fixes RUT generation, adds Laravel 11 and PHP 8.2/8.3 support, and clears out stale Dependabot pins.
Minimal path:
composer require astersnake/faker-chile --dev (it is almost always a dev/test dependency — you rarely generate fake Chileans in production).^1.0.4. Anything older can emit RUTs with a wrong check digit, which will blow up in assertDatabaseHas / validation tests.$faker = Faker\Factory::create('es_CL');
$faker->addProvider(new Astersnake\FakerChile\Providers\ChileProvider($faker));
In Laravel, if the package service provider is auto-discovered (check vendor/astersnake/faker-chile/composer.json → extra.laravel.providers), fake() and $this->faker in factories should already have the formatters. If not, bind it yourself in a FakerServiceProvider (see below).
First use case: a UserFactory / CompanyFactory that needs a valid Chilean RUT for feature tests around registration, invoicing, or SII-style documents. Look first at the provider class (src/Providers/ChileProvider.php) — the public methods there are your actual API surface, and the README's formatter list is the second thing to read because method names don't always mirror core Faker (rut() vs chileanRut() etc.).
Bind a configured generator once, use fake() everywhere. Rather than adding the provider in every test, resolve Faker through the container:
// app/Providers/FakerServiceProvider.php
public function register(): void
{
$this->app->singleton(\Faker\Generator::class, function () {
$faker = \Faker\Factory::create('es_CL');
$faker->addProvider(new \Astersnake\FakerChile\Providers\ChileProvider($faker));
return $faker;
});
}
Laravel's fake() helper resolves Faker\Generator from the container, so every factory and seeder inherits the Chilean formatters with no per-test boilerplate.
Factory states for Chilean entities. Wrap the package calls in named states so intent stays readable and you can swap providers later:
public function chilean(): static
{
return $this->state(fn () => [
'rut' => fake()->rut(),
'name' => fake()->name(),
'address' => fake()->address(),
'phone' => fake()->phoneNumber(),
]);
}
Seed deterministically for snapshot-style assertions. $this->seed(1234) before generating, or use fake()->seed() — combined with fake()->unique()->rut() you get stable data across runs without collisions in a unique index.
Pair geography data with geography data. If the provider exposes region/commune formatters, generate the commune first and derive the region from it (or hard-code a small map) rather than calling both independently — a Santiago address in the Aysén region is the classic tell of a fake Chilean record, and it will bite you in any test that filters by region.
Use it as a test fixture source, not a runtime generator. The realistic integration is Pest/PHPUnit tests and db:seed for local demos. If you need fake Chilean data in staging, prefer a dedicated seeder command guarded by app()->environment('local').
Generate the RUT and validate it in the same test. The point of 1.0.4 is that rut() now yields check-digit-correct values. Prove it in one test so a future downgrade or fork is caught immediately:
it('generates valid RUTs', function () {
foreach (range(1, 100) as $_) {
expect(ChileanRut::isValid(fake()->rut()))->toBeTrue();
}
});
1.0.3, any test asserting a valid RUT, or a factory feeding a form request with rut validation, may have been passing only because it never actually validated. Pre-1.0.4 fixtures in your repo may now look "wrong" — regenerate them.0-9 or K/k) or a small dedicated validator package. Do not assume fake()->rut() output passes assertDatabaseHas on a column with a DB-level constraint on formatting.12.345.678-5). If your DB column or API expects 123456785, normalize in the factory via str_replace(['.', '-'], '', ...) rather than patching the provider. Also normalize the check digit case — K vs k breaks naive string comparisons.fetch-metadata, laravel-pint-action). No runtime impact; skip them when reading the changelog for upgrade risk.illuminate/support in a small package is exactly where PHP 8.1 deprecations hide.Faker\Factory::create('es_CL') alone is not enough. The locale string selects the base Spanish provider, not the Chilean one. Without addProvider(), fake()->rut() throws BadMethodCallException: Unknown format "rut". If you see that, your container binding isn't winning over Laravel's default Faker singleton — check bind vs singleton and provider registration order.unique() is finite and stateful. fake()->unique()->rut() will eventually exhaust and throw. In a loop of hundreds of records, prefer a while with dedupe against the DB, or reset with fake()->unique(true) between tests.ChileProvider and add methods there rather than scattering fake()->numerify() hacks through factories — keeps the whole team on one API.How can I help you explore Laravel packages today?