PHPackages                             yulibo/hyperf-validate - 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. [Framework](/categories/framework)
4. /
5. yulibo/hyperf-validate

ActiveLibrary[Framework](/categories/framework)

yulibo/hyperf-validate
======================

支持request 和方法场景验证，兼容tp5写法 性能比官方验证器提高50%

2.0.2(5y ago)01.0k1Apache-2.0PHPPHP &gt;=7.2

Since Apr 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/yulibo/hyperf-validate)[ Packagist](https://packagist.org/packages/yulibo/hyperf-validate)[ RSS](/packages/yulibo-hyperf-validate/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (3)Dependencies (7)Versions (5)Used By (0)

hyperf-validate
===============

[](#hyperf-validate)

支持request 和方法场景验证，兼容tp5写法 性能比官方验证器提高50%

安装方法
----

[](#安装方法)

```
 安装方法  composer require yulibo/hyperf-validate

```

注：使用验证类方法的注解@Validation 需要用在由DI创建的类才有作用，

注解
--

[](#注解)

```
 @Validation
 @RequestValidation

```

### @RequestValidation 参数说明

[](#requestvalidation-参数说明)

```
mode="Admin" 默认取当前类文件名 验证的模块规则/app/Validate/AdminValidation.php 文件的验证规则
scene="场景" 场景，验证哪个场景。默认不写为默认的验证规则
filter=true 过滤掉规则外无用参数 过滤后会重新写入$this->request->getParsedBody()内，
              需要时直接取，数据是安全的，验证过的
throw=true 严格验证模式，如果开启，则用户传入无用参数，直接抛出异常，提示传入的字段xx无效，

```

### @Validation 参数说明

[](#validation-参数说明)

```
mode="Admin" 验证的模块规则/app/Validate/AdminValidation.php 文件的验证规则
scene="场景" 场景，验证哪个场景。默认不写为默认的验证规则
filter=true 过滤掉规则外无用参数 过滤后会重新写入对应的字段内，需要时直接取，数据是安全的，验证过的
throw=true 严格验证模式，如果开启，则用户传入无用参数，直接抛出异常，提示传入的字段xx无效，
field="data" 方法的参数名，例如 function($data,$array,$array3) 需要验证这个方法的$array参数，这里填array

```

验证控制器数据方法如下
-----------

[](#验证控制器数据方法如下)

### 例如 验证控制器Admin 的login方法传的数据，需要如下操作

[](#例如-验证控制器admin-的login方法传的数据需要如下操作)

```
use Ylb\Validate\Annotations\RequestValidation;

/**
 * @RequestValidation(filter=true,throw=true)
 */
public function login(){
      //这里取到的 $data 是安全的。
     $data = $this->request->getParsedBody();
}
```

验证类方法数据方法如下
-----------

[](#验证类方法数据方法如下)

例如 验证AdminService类的login方法传的数据，需要如下操作

```
use Ylb\Validate\Annotations\Validation;

/**
 * @Validation(mode="Admin",scene="login",field="data")
 * @Validation(mode="Admin",scene="array的规则",field="array")
 * @Validation(mode="Admin",scene="array2的规则",field="array2")
 */
public function login($data,$array,$array2){
      //这里取到的 $data,$array,$array2 是安全的，经过验证器验证过的

}
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

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

Total

4

Last Release

2144d ago

Major Versions

1.0.8 → 2.0.12020-07-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/22557c5417151a6ac664e50cae8bf92740627ada4f3cd8b251c54fb7ee7005e6?d=identicon)[yulibo](/maintainers/yulibo)

---

Top Contributors

[![yulibo](https://avatars.githubusercontent.com/u/3378440?v=4)](https://github.com/yulibo "yulibo (7 commits)")

---

Tags

phpframeworkswoolehyperf

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/yulibo-hyperf-validate/health.svg)

```
[![Health](https://phpackages.com/badges/yulibo-hyperf-validate/health.svg)](https://phpackages.com/packages/yulibo-hyperf-validate)
```

###  Alternatives

[hyperf/hyperf-skeleton

A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.

301187.4k](/packages/hyperf-hyperf-skeleton)[mzh/hyperf-validate

hyperf-validate 支持request 和方法场景验证，兼容tp5写法 支持控制器注解验证、方法注解验证

202.9k1](/packages/mzh-hyperf-validate)

PHPackages © 2026

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