承接 tandrewcl/api-request-convert 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

tandrewcl/api-request-convert

最新稳定版本:v1.1.0

Composer 安装命令:

composer require tandrewcl/api-request-convert

包简介

Convert request content to DTO classes

README 文档

README

About bundle

This bundle is a simple solution to convert request to DTO classes

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

    $ composer require tandrewcl/api-request-convert

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Step 2: Config and Usage

Thanks for Symfony flex Bundle is auto enabled in config/bundles.php

...
use tandrewcl\ApiRequestConvertBundle\DTO\ResolvableInputDTOInterface;
...

class LoginDTO implements ResolvableInputDTOInterface
{
    #[Assert\NotBlank]
    #[Assert\Length(max: 16)]
    public ?string $login = null;

    #[Assert\NotBlank]
    #[Assert\Length(max: 16)]
    public ?string $password = null;

    public function handleRequest(Request $request): void
    {
        $params = $request->request->all();
        $this->login = $params['login'] ?? null;
        $this->password = $params['password'] ?? null;
    }
}
...
use tandrewcl\ApiResponseConvertBundle\Handler\ResponseHandler;
...

class FooController
{
    public function loginAction(LoginDTO $loginDTO): Response
    {
        ...
        $authResult = $authService->auth($loginDTO->login, $loginDTO->password);
        ...
    }

统计信息

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

GitHub 信息

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

其他信息

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