PHPackages                             dashingunique/think-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. dashingunique/think-generator

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

dashingunique/think-generator
=============================

thinkphp6 random generation of mobile phone number, ID number, mailbox address, nickname and other test data.

v1.0.3(6y ago)13642[1 issues](https://github.com/dashingunique/think-generator/issues)MITPHPPHP &gt;=7.0

Since May 29Pushed 6y agoCompare

[ Source](https://github.com/dashingunique/think-generator)[ Packagist](https://packagist.org/packages/dashingunique/think-generator)[ RSS](/packages/dashingunique-think-generator/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (4)DependenciesVersions (5)Used By (0)

think-generator
===============

[](#think-generator)

**thinkphp6 随机生成手机号、身份证号、邮箱地址、昵称等测试数据**

**特此申明：本类的初衷是生成测试数据，不可进行任何违法行为，不可进行任何违法行为，不可进行任何违法行为！！！**

Installation
------------

[](#installation)

通过在composer.json中配置安装：

```
composer require dashingunique/think-generator
```

or

```
// composer.json
composer install
// composer update
composer update
```

Usage
-----

[](#usage)

\*\*

生成手机号码
------

[](#生成手机号码)

\*\*

```
$generator = (new Generator($this->app))->generator('mobile');

//随机生成一个手机号
$generator->get();  //13611111111

//随机生成一个号段为182的手机号
$generator->prefix(182)->get();//18211111111

//允许13,14,15,17,18,19号段的手机号生成（从中生成一个号码段）
$generator->allow([3, 4, 5, 7, 8, 9])->get();//13011111111

//获取多个手机号
$generator->limit(10)->get();

//若同时存在prefix 和 allow prefix强制覆盖allow
$generator->prefix(182)->allow([3, 4, 5, 7, 8, 9])->limit(10)->get();//18211111111
```

生成邮箱地址
------

[](#生成邮箱地址)

\*\*

```
$generator = (new Generator($this->app))->generator('email');

//随机生成一个邮箱地址
$generator->get();//12345678@qq.com

//随机生成一个前缀为123456789的邮箱
$generator->prefix(123456789)->get();//123456789@163.com

//随机生成一个后缀为@qq.com的邮箱
$generator->suffix('@qq.com')->get();//12345678@qq.com

//生成一个指定长度的邮箱地址
$generator->length(6)->get();//123456@qq.com

//获取多个邮箱
$generator->limit(10)->get();
```

### 生成身份证号码

[](#生成身份证号码)

```
$generator = (new Generator($this->app))->generator('identity');

//随机生成一个身份证号码
$generator->get();

//随机生成一个指定性别的身份证号码（1男性 2女性）
$generator->sex(1)->get();

//随机生成一个北京市的身份证号码
$generator->province('北京市')->get();

//随机生成一个省份城市的身份证号码
$generator->city('成都市')->get();

//随机生成一个地区的身份证号码
$generator->city('高新区')->get();

//随机生成一个指定出生日期的身份证号码
$generator->birthday('2000-01-01')->get();

//获取多个身份证号码
$generator->limit(10)->get();
```

生成昵称
----

[](#生成昵称)

```
$generator = (new Generator($this->app))->generator('nickname');

//随机生成一个用户昵称
$generator->get();

//随机生成一个指定姓氏的用户昵称
$generator->surname('张')->get();//张三

//随机生成一个指定姓氏类型的用户昵称（1单姓 2复姓）
$generator->compound(2)->get();//上官三

//随机生成一个指定性别的用户昵称（1男性 2女性）
$generator->sex(2)->get();//张美

//获取一个指定长度的用户昵称
$generator->length(3)->get();//张大麻子

//获取多个用户昵称
$generator->limit(10)->get();
```

```

## 后续
增加银行卡号的生成
验证生成的数据为一性
增加数据驱动类型：本地文件、Redis、数据库

```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Every ~0 days

Total

4

Last Release

2224d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33447637?v=4)[Dragon Li](/maintainers/dashingunique)[@dashingunique](https://github.com/dashingunique)

---

Top Contributors

[![dashingunique](https://avatars.githubusercontent.com/u/33447637?v=4)](https://github.com/dashingunique "dashingunique (11 commits)")

---

Tags

generatorthinkphp6tp6

### Embed Badge

![Health badge](/badges/dashingunique-think-generator/health.svg)

```
[![Health](https://phpackages.com/badges/dashingunique-think-generator/health.svg)](https://phpackages.com/packages/dashingunique-think-generator)
```

###  Alternatives

[symfony/firebase-notifier

Symfony Firebase Notifier Bridge

12917.4k1](/packages/symfony-firebase-notifier)[jofrysutanto/windsor

YAML-ised Configuration for ACF

549.2k](/packages/jofrysutanto-windsor)

PHPackages © 2026

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