Download the PHP package lil-pecky/random-person-generator without Composer
On this page you can find all versions of the php package lil-pecky/random-person-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package 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.
Getting started
Installation
This package requires PHP >= 8.1.
composer require lil-pecky/random-person-generator
Usage
There's two ways to instantiate a Generator instance;
Providing a specific locale to the factory
Randomising the locale, providing an optional language
In both cases, the provided language must be present in the
array, an exception will be thrown if an invalid language has been provided.
Generating a person, or multiple people
Available methods
As this package has mainly been written to fit a very specific use case, the amount of available methods is limited;
Some languages, like Icelandic, have gendered last names, so an optional gender can be provided to the familyName
method
Source data
The names for each language/country have been generated using ChatGPT, and have been supplemented by FakerPHP names whenever possible.
Contributing
Adding names to locales
There are two ways of adding names;
- adding them to a specific locale's JSON file
- adding them to a specific locale's
Name.php
file
Adding names to a specific locale's 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
& female
for given names, family
, family_male
& family_female
for given names, middle
for middle
names).
Afterwards, run
to add the newly added names to the appropriate PHP files.
Adding names to a specific locale's Name.php
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
to add the newly added names to the appropriate JSON files.
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
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
array, with the ISO 639-1 language code as key and the language name as
value (for example, 'af' => 'Afrikaans'
).