death_satan/think-dto 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

death_satan/think-dto

最新稳定版本:v1.0.0

Composer 安装命令:

composer require death_satan/think-dto

包简介

Dto package for thinkphp6

README 文档

README

安装 (php>=8.0)

composer require death_satan/think-dto -vvv

使用

创建DTO类

<?php


namespace app\dto;


use think\route\annotation\Rule;
use think\route\annotation\Validate;

// 指定验证器对整个类所有的属性进行验证 第二个参数指定场景
#[Validate(\app\validate\Test::class)]
class Test
{
    // 也可以单独对某一个属性进行二次规则验证
    #[Rule(values: 'require')]
    public int $dto;
}

在控制器中使用

<?php
namespace app\controller;

use app\BaseController;
use app\dto\Test;
use think\route\annotation\RequestBody;
use think\route\annotation\RequestQuery;

class Index extends BaseController
{
    // RequestQuery 将get参数放到test类属性中
    public function index(#[RequestQuery] Test $data)
    {
    }

    // RequestBody 将当前请求中的参数放到test类中
    public function test(#[RequestBody] Test $data)
    {

    }
}

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固