PHPackages                             eric-strive/hyperf-tool - 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. eric-strive/hyperf-tool

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

eric-strive/hyperf-tool
=======================

A Devtool for Hyperf.

v1.2.30(4y ago)61.1k1[1 issues](https://github.com/eric-strive/hyperf-tool/issues)MITPHPPHP &gt;=7.2

Since Nov 26Pushed 4y ago1 watchersCompare

[ Source](https://github.com/eric-strive/hyperf-tool)[ Packagist](https://packagist.org/packages/eric-strive/hyperf-tool)[ Docs](https://hyperf.io)[ RSS](/packages/eric-strive-hyperf-tool/feed)WikiDiscussions main Synced 4d ago

READMEChangelogDependencies (9)Versions (22)Used By (0)

[hyperf-tool](https://github.com/eric-strive/hyperf-tool)
=========================================================

[](#hyperf-tool)

功能
--

[](#功能)

- 该组件主要是根据开发扩展一些hyperf的工具，主要有gii工具、swagger的扩展等... 持续跟进中。。。

### 下载安装包

[](#下载安装包)

```
composer require eric-strive/hyperf-tool

```

### 同步配置

[](#同步配置)

```
php bin/hyperf.php vendor:publish eric-strive/hyperf-tool
```

- swagger模板配置在`App\Constants\SwaggerTemplate`，可以将重复出现的swagger配置在`SwaggerTemplate`中， 可以极大的简化controller swagger代码量

### swagger使用示例 这里需要配合 [daodao97/apidog](https://github.com/daodao97/apidog) 使用，感谢 `hyperf`开发中之一刀哥提供如此好用的`swagger`

[](#swagger使用示例-这里需要配合-daodao97apidog-使用感谢-hyperf开发中之一刀哥提供如此好用的swagger)

- ValidationRequest ：template：是配置的模板，这可以将很复杂的注解简化

```
@ValidationRequest(template="authorization")
```

- BodyValidation 简化body,这里将结合Request，可以将校验和Request结合，可以复用配置校验

```
@BodyValidation(validate="DictDetailRequest",scene="search",template="page_search")
```

- SwaggerResponse 这里是扩展了ApiResponse,可以极大的依赖Request，达到复用以及简化controller代码

```
@SwaggerResponse(responseClass="DictDetailRequest",scene="response",template="page")
```

### 代码生成

[](#代码生成)

- 现将model代码复制放入app\\Model
- controller自动生成

```
php bin/hyperf.php make:controller TestUserController TestModel 测试我的功能
```

- request自动生成

```
php bin/hyperf.php make:request RoleRequest roles
```

### 导入导出工具

[](#导入导出工具)

- 导入

```
$excelImport = new Import($file, $startRow, $endVerifyLine);
        $excelImport->process(function ($saveData) {
            // 处理$saveData
        }, $format);
$file ：导入的文件对象，UploadedFile对象
$startRow：文件开始读取的行，如果需要过滤前面的数据可以使用
$endVerifyLine：验证的列，这里防止文件后面空行过多导致报错，验证的行为空时直接终止取数

$saveData：获取的数据
$format：数据对应格式，具体行对应的字段配置
eg:
[
    'email'      => 2,
    'phone'      => 1,
    'user_name'  => 0,
    'real_name'  => 3,
    'job_number' => 0,
]
这里是字段分别对应的列，逻辑会自动根据对应的列来处理数据

```

- 导出

```
Download::downloadCsv($fileName, $data, true),$format);
$fileName:导出文件名称
$data:导出数据，这里可以是数组和对象，对象需要时model的对象
$format：数据处理的格式
eg:
[
    [
        'label' => "真实姓名",
        'value' => 'real_name',
        'width' => 15,
    ],
    [
        'label' => "创建时间",
        'value' => 'created_at',
        'width' => 20,
    ],
    [
        'label' => "类型",
        'value' => static function ($model) use ($employeeType) {
            return getExistParam($employeeType, $model->type);
        },
        'width' => 5,
    ],
]
上面配置：
label：csv头信息
value：取的对象或数组的值，可以是函数
width：该列的宽度，根据实际调整

Download::downloadCsv('test.csv', [[
    'real_name'=>'王五',
    'created_time'=>'2020-01-02 10:02:12',
    'type'=>'测试',
],[
    'real_name'=>'张三',
    'created_at1'=>'2020-01-23',
    'type'=>'类型',
]], [
    [
        'label' => "真实姓名",
        'value' => 'real_name',
        'width' => 15,
    ],
    [
        'label' => "创建时间",
        'value' => 'created_time',
        'width' => 20,
    ],
    [
        'label' => "类型",
        'value' => static function ($model) {
            return $model['type'] . '测试类型';
        },
        'width' => 5,
    ],
]);

```

#### 有任何问题请联系 `eric-strive@qq.com`

[](#有任何问题请联系-eric-striveqqcom)

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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 ~9 days

Recently: every ~20 days

Total

21

Last Release

1811d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/578876?v=4)[wangwei](/maintainers/wangwei)[@wangwei](https://github.com/wangwei)

---

Top Contributors

[![eric-strive](https://avatars.githubusercontent.com/u/22976965?v=4)](https://github.com/eric-strive "eric-strive (1 commits)")

---

Tags

phpswoolehyperfdevtool

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/eric-strive-hyperf-tool/health.svg)

```
[![Health](https://phpackages.com/badges/eric-strive-hyperf-tool/health.svg)](https://phpackages.com/packages/eric-strive-hyperf-tool)
```

PHPackages © 2026

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