Download the PHP package wayhood/hyperf-dto without Composer
On this page you can find all versions of the php package wayhood/hyperf-dto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download wayhood/hyperf-dto
More information about wayhood/hyperf-dto
Files in wayhood/hyperf-dto
Download wayhood/hyperf-dto
More information about wayhood/hyperf-dto
Files in wayhood/hyperf-dto
Please rate this library. Is it a good library?
Informations about the package hyperf-dto
PHP Swagger Api Docs
基于 Hyperf 框架的 DTO 类映射
优点
- 请求参数映射到PHP类
- 代码可维护性好,扩展性好
- 支持数组,递归,嵌套
- 支持框架数据验证器
缺点
- 模型类需要手工编写
注意
php >= 8.0
安装
使用
1. 使用
注解
命名空间:
Hyperf\DTO\Annotation\Contracts
RequestBody
- 获取Body参数
RequestQuery
- 获取GET参数
RequestFormData
-
获取表单请求
-
获取文件(和表单一起使用)
- 获取Body参数和GET参数
注意: 一个方法,不能同时注入RequestBody和RequestFormData
示例
控制器
验证器
基于框架的验证
安装hyperf框架验证器hyperf/validation, 并配置(已安装忽略)
- 注解
Required
Between
Date
Email
Image
Integer
Nullable
Numeric
Url
Validation
- 校验生效
只需在控制器方法中加上 #[Valid] 注解
- Validation
rule 支持框架所有验证
- 自定义验证注解 只需继承
Hyperf\DTO\Annotation\Validation\BaseValidation
即可
注意
- 映射数组类时,
@var
需要写绝对路径 - 控制器中使用了框架
AutoController
注解,只收集了POST
方法
All versions of hyperf-dto with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.0
netresearch/jsonmapper Version ^4.0
hyperf/http-server Version 3.0.x-dev
hyperf/di Version 3.0.x-dev
hyperf/json-rpc Version 3.0.x-dev
hyperf/rpc-server Version 3.0.x-dev
hyperf/validation Version 3.0.x-dev
symfony/serializer Version ^5.0
jetbrains/phpstorm-attributes Version ^1.0
netresearch/jsonmapper Version ^4.0
hyperf/http-server Version 3.0.x-dev
hyperf/di Version 3.0.x-dev
hyperf/json-rpc Version 3.0.x-dev
hyperf/rpc-server Version 3.0.x-dev
hyperf/validation Version 3.0.x-dev
symfony/serializer Version ^5.0
jetbrains/phpstorm-attributes Version ^1.0
The package wayhood/hyperf-dto contains the following files
Loading the files please wait ....