PHPackages                             lil-pecky/random-person-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. lil-pecky/random-person-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

lil-pecky/random-person-generator
=================================

1.0.0(3y ago)92.6k↓50%2[1 issues](https://github.com/lolsokje/random-person-generator/issues)MITPHPPHP ^8.1

Since Apr 4Pushed 3y ago1 watchersCompare

[ Source](https://github.com/lolsokje/random-person-generator)[ Packagist](https://packagist.org/packages/lil-pecky/random-person-generator)[ RSS](/packages/lil-pecky-random-person-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Random Person Generator
=======================

[](#random-person-generator)

This package allows you to generate people with random names, birthdays and country of birth. The country of birth can either be completely random, or based on a provided language.

This package has been developed to fit a very specific use case, but since a list of random names can be useful for many projects, I decided to publish it.

This package is heavily influenced/inspired by [FakerPHP](https://github.com/FakerPHP/Faker).

Getting started
---------------

[](#getting-started)

### Installation

[](#installation)

This package requires PHP &gt;= 8.1.

`composer require lil-pecky/random-person-generator`

### Usage

[](#usage)

There's two ways to instantiate a Generator instance;

#### Providing a specific locale to the factory

[](#providing-a-specific-locale-to-the-factory)

```
use LilPecky\RandomPersonGenerator\Factory;
use LilPecky\RandomPersonGenerator\Locale;

// the provided locale is required
$locale = Locale::create('nl_NL');
$generator = Factory::create($locale);
```

#### Randomising the locale, providing an optional language

[](#randomising-the-locale-providing-an-optional-language)

```
use LilPecky\RandomPersonGenerator\Factory;

// generator for a completely random locale (en_GB, fr_FR, pt_BR, ...)
$generator = Factory::createWithRandomLocale();

// generator for a random locale within a specific language (nl_BE or nl_NL)
$generator = Factory::createWithRandomLocale('nl');
```

In both cases, the provided language must be present in the

```
LilPecky\RandomPersonGenerator\Languages::LANGUAGES
```

array, an exception will be thrown if an invalid language has been provided.

### Generating a person, or multiple people

[](#generating-a-person-or-multiple-people)

```
$locale = Locale::create('nl_NL');
$generator = Factory::create($locale);

$amount = new Amount(10);
$startDate = '2013-01-01';
$endDate = '2023-01-01';
$gender = Gender::FEMALE;

// generates a single Dutch person, with a male given name and date of birth between $startDate and $endDate
$person = $generator->person($startDate, $endDate, $gender);

// generates 10 Dutch people, each with a male given name and date of birth between $startDate and $endDate
$people = $generator->people($amount, $startDate, $endDate, $generator);
$people = $generator->persons($amount, $startDate, $endDate, $generator);
```

### Available methods

[](#available-methods)

As this package has mainly been written to fit a very specific use case, the amount of available methods is limited;

```
require_once 'vendor/autoload.php';

$locale = Locale::create('nl_NL');
$generator = Factory::create($locale);

// generates a random date between two bounds.
// if no start date is provided, it defaults to now - 30 years. Can also be a DateTimeImmutable object
// if no end date is provided, it defaults to now. Can also be a DateTimeImmutable object
$generator->dateBetween('2013-01-01', '2023-01-01');

// generates a random male Dutch given name
// if no gender is provided, it defaults to Gender::MALE
$generator->givenName(Gender::MALE);

// generates a random Dutch family name
$generator->familyName();
```

Some languages, like Icelandic, have gendered last names, so an optional gender can be provided to the `familyName`method

```
$locale = Locale::create('is_IS');
$generator = Factory::create($locale);

echo $generator->familyName(Gender::FEMALE);
// Eiðsdóttir

echo $generator->familyName(Gender::MALE);
// Þorfinnsson
```

Source data
-----------

[](#source-data)

The names for each language/country have been generated using [ChatGPT](https://chat.openai.com/chat), and have been supplemented by [FakerPHP](https://github.com/FakerPHP/Faker) names whenever possible.

Contributing
------------

[](#contributing)

### Adding names to locales

[](#adding-names-to-locales)

There are two ways of adding names;

1. adding them to a specific locale's JSON file
2. adding them to a specific locale's `Name.php` file

#### Adding names to a specific locale's JSON file

[](#adding-names-to-a-specific-locales-json-file)

To add names to a locale's JSON file, open the locale's file in the `data` directory and add names to the appropriate types (`male` &amp; `female` for given names, `family`, `family_male` &amp; `family_female` for given names, `middle` for middle names).

Afterwards, run

```
php scripts/generate-php-from-json.php
```

to add the newly added names to the appropriate PHP files.

#### Adding names to a specific locale's `Name.php` file

[](#adding-names-to-a-specific-locales-namephp-file)

To add names to a locale's `Name.php` file, open that file in the `src/Providers/{locale}` directory and add the names to the appropriate properties.

Afterwards, run

```
php scripts/generate-json-from-php.php
```

to add the newly added names to the appropriate JSON files.

### Adding new locales

[](#adding-new-locales)

Adding a new locale is pretty simply. Create a new directory in the `src/Providers` directory in the correct format (`ab_CD`), and in the new directory create a `Name.php` file.

The new `Name.php` file must extend

```
LilPecky\RandomPersonGenerator\Providers\Name::class
```

#### Adding new languages

[](#adding-new-languages)

If the locale you've added a locale for which no language exists yet (for example, af\_ZA for Afrikaans/South Africa), it would be appreciated if you add the new language to the

```
LilPecky\RandomPersonGenerator\Languages::LANGUAGES
```

array, with the [ISO 639-1](https://en.wikipedia.org/wiki/ISO_639-1) language code as key and the language name as value (for example, `'af' => 'Afrikaans'`).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1135d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/965550677a297462169d5a97812fe77c99af384d0dfc8ca6d4561920aa05dafe?d=identicon)[lolsokje](/maintainers/lolsokje)

---

Top Contributors

[![lolsokje](https://avatars.githubusercontent.com/u/12721617?v=4)](https://github.com/lolsokje "lolsokje (26 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/lil-pecky-random-person-generator/health.svg)

```
[![Health](https://phpackages.com/badges/lil-pecky-random-person-generator/health.svg)](https://phpackages.com/packages/lil-pecky-random-person-generator)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
