Download the PHP package webman-tech/dto without Composer

On this page you can find all versions of the php package webman-tech/dto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package dto

webman-tech/dto

本项目是从 webman-tech/components-monorepo 自动 split 出来的,请勿直接修改

简介

webman 数据传输对象(DTO)组件,提供一套完整的数据处理解决方案,包括数据验证、类型转换、请求处理、响应生成等功能。

该组件通过属性注解和反射机制,实现了自动化的数据处理流程,解决了手动处理数据时容易出错、代码重复等问题。

功能特性

安装

核心组件

BaseDTO 基础数据传输对象

BaseDTO 是所有 DTO 的基类,提供核心功能,包括从数组创建 DTO 实例(fromData())、将 DTO 转换为数组(toArray())、数据验证和类型转换,以及自定义验证规则支持。

BaseRequestDTO 请求数据传输对象

BaseRequestDTO 用于处理 HTTP 请求数据,支持通过 fromRequest() 从请求中自动提取数据,并支持多种请求数据来源(Query、Form、JSON、Header、Cookie 等)。

BaseResponseDTO 响应数据传输对象

BaseResponseDTO 用于生成 HTTP 响应,通过 toResponse() 输出响应,支持自定义响应头、状态码和响应格式。

BaseConfigDTO 配置数据传输对象

BaseConfigDTO 用于处理应用配置,通过 fromConfig() 从配置创建实例,支持配置合并和默认值,适用于复杂的配置场景。默认不校验传入数据以兼顾性能。

属性注解

ValidationRules 验证规则

ValidationRules 是核心验证注解,支持必填、字符串/整数/数组/枚举/嵌套对象等类型验证、数值范围、字符串长度、自定义规则等多种验证选项。DTO 会自动根据属性的 PHP 类型声明和是否有默认值推断必填和数据类型验证,只在需要额外约束时才需要显式添加注解。

ToArrayConfig 数组转换配置

ToArrayConfig 用于控制 DTO 转换为数组的行为,支持仅包含指定字段(only)、排除指定字段(exclude)、忽略空值(ignoreNull)、空数组转为空对象(emptyArrayAsObject)、单字段值直接作为结果(singleKey)等选项。也可在调用 toArray() 时临时传入覆盖类级别的配置。

RequestPropertyIn 请求属性来源

用于指定请求中各属性的数据来源,包括:

DTO 代码生成器(Web 版)

仓库提供了一个前端版本的 DTO 代码生成器,构建产物位于 web/index.html,特点如下:

AI 辅助


All versions of dto with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
webman-tech/common-utils Version ^5.0 || dev-main
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package webman-tech/dto contains the following files

Loading the files please wait ...