dreamcat/ctl-param-generator-4-laravel

控制器参数生成的laravel适配器

v1.2.0 2024-02-29 09:13 UTC

This package is auto-updated.

Last update: 2024-03-29 09:39:16 UTC


README

介绍

通过注解的形式直接生成控制器参数

安装

composer require dreamcat/ctl-param-generator-4-laravel

使用方法

加入 provider

  • \DreamCat\ControllerParamGen4Laravel\Provider\CtlParamGenProvider

配置定义

配置文件放在 config/controllerParamGenerator.php

配置路径类型含义默认值
arrayConverter.createNewPropertybool生成参数时是否创建对象原本不存在的属性false
arrayConverter.tryWithoutConstructorbool如果参数的类无法调用构造函数时是否尝试执行不调用构造函数创建对象false
arrayConverter.tryCallSetterbool如果属性有set方法是否尝试调用true
arrayConverter.tryConstructWithParambool如果构造函数仅有一个必填参数,尝试在构造函数只有一个参数时调用构造函数true
arrayConverter.propertyAnalysisstring属性分析器的bean名类名,必须实现接口 \Dreamcat\PropertyAnalysis\PropertyAnalysisInterface 才有效null
bodyDecodersstring[]特定content-type的消息解码器,必须实现接口 \DreamCat\ControllerParamGen\HttpBodyDecodeInterfacenull
specParamsMap<string, string>特殊类的构造器,键是类名,值是对应的bean,必须实现接口 \DreamCat\ControllerParamGen\ParamCreateInterfacenull
jsonCoder.transMode0 / 1 / 21 表示会自动将对象的驼峰风格与参数的下划线风格互相映射, 2 表示会自动将对象的下划线风格与参数的驼峰风格互相映射0
jsonCoder.ignoreUndefinebool对响应对象中未赋值的字段是否不做输出true