grantholle/laravel-username-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

grantholle/laravel-username-generator

最新稳定版本:2.1.0

Composer 安装命令:

composer require grantholle/laravel-username-generator

包简介

Generate a random, kid-safe username.

README 文档

README

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.

统计信息

  • 总下载量: 34.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固