Download the PHP package yjyer/php-dto without Composer
On this page you can find all versions of the php package yjyer/php-dto. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download yjyer/php-dto
More information about yjyer/php-dto
Files in yjyer/php-dto
Download yjyer/php-dto
More information about yjyer/php-dto
Files in yjyer/php-dto
Please rate this library. Is it a good library?
Informations about the package php-dto
php-dto
运行环境要求PHP8.0或以上
主要新特性
- 支持类似Java DTO
安装
安装
composer require yjyer/php-dto
卸载
composer remove yjyer/php-dto
使用方法
在thinkphp6框架文件:/vendor/topthink/framework/src/think/Container.php 里的方法:invokeReflectMethod 下增加如下代码,如:
/**
* dto模块运行入口
* 1、此代码需要手动增加
* 2、每次更新tp核心框架后,如果此方法(Container/invokeReflectMethod)没有此代码,则需要增加
*/
$args = \yjyer\phpdto\Main::actionInject($reflect, $args, $vars);
完整方法如:
/**
* 调用反射执行类的方法 支持参数绑定
* @access public
* @param object $instance 对象实例
* @param mixed $reflect 反射类
* @param array $vars 参数
* @return mixed
*/
public function invokeReflectMethod($instance, $reflect, array $vars = [])
{
$args = $this->bindParams($reflect, $vars);
/**
* dto模块运行入口
* 1、此代码需要手动增加
* 2、每次更新tp核心框架后,如果此方法(Container/invokeReflectMethod)没有此代码,则需要增加
*/
$args = \yjyer\phpdto\Main::actionInject($reflect, $args, $vars);
return $reflect->invokeArgs($instance, $args);
}
dto类配置
Validate的验证规则,和thinkphp6是一样的用法,查看:https://www.kancloud.cn/manual/thinkphp6_0/1037625
控制器内的使用
All versions of php-dto with dependencies
PHP Build Version
Package Version
Requires
php Version
>=8.0
The package yjyer/php-dto contains the following files
Loading the files please wait ...