grantholle/laravel-username-generator

Generate a random, kid-safe username.
69,989 4
Install
composer require grantholle/laravel-username-generator
Latest Version:2.2.0
PHP:^8.2
License:MIT
Last Updated:Jul 2, 2026
Links: GitHub  ·  Packagist
Maintainer: grantholle

Generate a random, kid-safe username.

Latest Version on Packagist GitHub Tests Action Status Total Downloads

Generate a username with flexible configuration options. For now the nouns are animal names.

Installation

You can install the package via composer:

composer require grantholle/laravel-username-generator

You can optionally publish the config file with:

php artisan vendor:publish --tag="laravel-username-generator-config"

By default, it will generate a username studly case with 1 adjective, 1 noun and no numeric prefix. You can modify the config file with your preferred numbers:

return [
    'adjectives' => 2,
    'nouns' => 1,
    'digits' => 2,
    // The casing leverages Laravel's string helper functions:
    // "lower", "upper", "studly", "kebab", "camel", "snake", "slug"
    'casing' => 'slug',
];

Usage

You can leverage your config setup to generate a username based on those options. Using the above configuration as an example, this would generate a username as adjective-adjective-noun-##:

use GrantHolle\UsernameGenerator\Username;

$username = Username::make();
// grave-tame-tiger-60

Or, if you want to configure your username on the fly, you can use a fluent API to build your username:

use GrantHolle\UsernameGenerator\Username;

$username = (new Username)
    ->withAdjectiveCount(2)
    ->withNounCount(2)
    ->withDigitCount(4)
    ->withCasing('snake')
    ->generate();
// gentle_wan_chimpanzee_sandpiper8828

Command

This also comes with a make:username command to generate a username from the command line:

# This will use what's in your configuration file
php artisan make:username
# personal-unrealistic-eland-30

You can pass in a number of options to change how the username is generated:

php artisan make:username --count 2 --digits 8 --casing studly
# OrdinaryHerring02683641
# WittyGoat89531555
Options:
  -c, --casing[=CASING]          The casing to use: "lower", "upper", "studly", "kebab", "camel", "snake", or "slug".
  -d, --digits[=DIGITS]          The number of digits to use for a prefix.
  -a, --adjectives[=ADJECTIVES]  The number of adjectives to use.
  -N, --nouns[=NOUNS]            The number of nouns to use.
  -C, --count[=COUNT]            The number of usernames to generate. [default: "1"]

Testing

composer test
composer analyse

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Want to add a noun or adjective? Please see CONTRIBUTING for details.

License

The MIT License (MIT). Please see License File for more information.

Related Packages

hansdeboeck/laravel-username-generator

Generate a random, kid-safe username.

2,893 0
farzad1120/laraveluser

The Laravel Framework with user verification functionality.

25 0
luilliarcec/laravel-username-generator

Laravel Username Generator is a package that allows the versatile generation of...

12,337 11
gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0