PHPackages                             mzh/helper - 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. mzh/helper

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

mzh/helper
==========

A helper component for hyperf.

v0.1.7(5y ago)441MITPHPPHP &gt;=7.2

Since Jul 14Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lphkxd/hyperf-helper)[ Packagist](https://packagist.org/packages/mzh/helper)[ RSS](/packages/mzh-helper/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (8)Dependencies (6)Versions (9)Used By (0)

hyperf-helper
=============

[](#hyperf-helper)

hyperf-helper 工具助手，自动生成service、api控制器、验证器 安装方法

```
composer require mzh/hyperf-helper
```

\#常用方法

```
Redis()          #获取redis实例
Logger()         #获取日志实例
getClientIp()    #获取客户端ip
getContainer()   #获取DI容器
verifyIp()       #验证IP有效性
p()              #打印调试日志到控制台
uuid(32)         #生成不重复的字符串
filterEmoji（）   #filterEmoji表情过滤
convertHump()    #数组驼峰key 转下划线key
session()        #设置Session管理
getSession（）    #获取session实例
sessionDestroy() #销毁当前Session实例

```

### 工具1 QueryHelper

[](#工具1-queryhelper)

第一步 引入

```
use GetQueryHelper;
```

第二步使用：

```
        //获得模型
        $userModel = User::query();
        //（1）可以再模型设置条件，join 之类的
        $userModel->where('id', 1)->where('status', 1);

        //引入QueryHelper  第一个参数传模型对象，第二个参数传 数组分页查找
        $query = $this->QueryHelper($userModel, $data);

        //如果不用（1）方法也可以在引入引入QueryHelper后再对模型进行
        $query->query->where('id', 1);
        $query->query->join('','','','');
        //...等等所有模型操作

        // 切入url参数，接收 username 和 keywords 并使用 like 查询，接收 user_id is_top 使用 eq 查询
        $query->equal('user_id,is_top');
        $query->like('username,keywords');
        //用法1
        $query->timeBetween('字段');
        $query->timeBetween([
            '开始时间字段',
            '结束时间字段'
        ]);
        $query->dateBetween('日期字段');
        $query->dateBetween([
            '开始日期字段',
            '结束日期字段'
        ]);
        //启用自动分页 paginate 第一个参数可选，列表返回字段，第二个参数可以传一个匿名函数 可以再里面修改返回列表集合
        return $query->paginate();
```

\#工具2 自动生成工具依赖

gen:api
-------

[](#genapi)

自动生成api文件，自动把swagger注解，和常用代码给生成出来

#### 参数1：类名

[](#参数1类名)

#### 参数2：当前模块名字（swagger上展示用）

[](#参数2当前模块名字swagger上展示用)

#### 参数3：绑定哪个服务（不写为当前类名+Service)

[](#参数3绑定哪个服务不写为当前类名service)

#### 参数4：当前模块介绍（swagger上展示用）

[](#参数4当前模块介绍swagger上展示用)

例如生成api User控制器(支持多级目录)：

```
php bin/hyperf.php gen:api User 用户控制器 UserService 介绍
执行后会在 App/Controller里生成User.php 类

#多级目录
php bin/hyperf.php gen:api Api/v1/User 用户控制器 UserService 介绍
执行后会在 App/Controller/api/v1/下生成User.php 类
```

gen:service
-----------

[](#genservice)

自动生成service文件，把常用代码给生成出来

```
php bin/hyperf.php gen:service User
执行后会在 App\Serivce 里生成UserService.php 类
```

gen:validate
------------

[](#genvalidate)

自动生成验证器文件，把常用规则给生成出来

```
php bin/hyperf.php gen:validate User
执行后会在 App\Validate 里生成UserValidation.php 类并把默认规则填入
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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

Total

8

Last Release

2098d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6064d6ea21c78c19ac11c7918d833822adf51797f1920b2c1b45968795a71074?d=identicon)[lphkxd](/maintainers/lphkxd)

---

Top Contributors

[![lphkxd](https://avatars.githubusercontent.com/u/16346895?v=4)](https://github.com/lphkxd "lphkxd (26 commits)")

---

Tags

phphelperhyperf

### Embed Badge

![Health badge](/badges/mzh-helper/health.svg)

```
[![Health](https://phpackages.com/badges/mzh-helper/health.svg)](https://phpackages.com/packages/mzh-helper)
```

###  Alternatives

[hyperf/watcher

Hot reload watcher for Hyperf

17846.7k27](/packages/hyperf-watcher)

PHPackages © 2026

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