Download the PHP package tangwei/dto without Composer
On this page you can find all versions of the php package tangwei/dto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package dto
PHP Swagger DTO
基于 Hyperf 框架的 DTO 类映射
优点
- 请求参数映射到PHP类
- 代码可维护性好,扩展性好
- 支持数组,递归,嵌套
- 支持框架数据验证器
注意
- 模型类需要手工编写
- php >= 8.1
安装
使用
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
即可
RPC 返回PHP对象
aspects.php中配置
当框架导入 symfony/serializer (^5.0) 和 symfony/property-access (^5.0) 后,并在 dependencies.php 中配置一下映射关系
All versions of dto with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.1
netresearch/jsonmapper Version ~4.4.1
hyperf/http-server Version ~3.0.0|~3.1.0
hyperf/di Version ~3.0.0|~3.1.0
hyperf/validation Version ~3.0.0|~3.1.0
phpdocumentor/reflection-docblock Version ^5.0
netresearch/jsonmapper Version ~4.4.1
hyperf/http-server Version ~3.0.0|~3.1.0
hyperf/di Version ~3.0.0|~3.1.0
hyperf/validation Version ~3.0.0|~3.1.0
phpdocumentor/reflection-docblock Version ^5.0
The package tangwei/dto contains the following files
Loading the files please wait ....