bluestone/dto
Composer 安装命令:
composer require bluestone/dto
包简介
Data transfer objects
README 文档
README
Installation
This package requires php:^8.1.
You can install it via composer:
composer require bluestone/dto
Usage
This package goal to simplify the build of objects whose serve to pass structured data.
Build simple DTO
An exemple of class extends DTO :
use Bluestone\DataTransferObject\DataTransferObject; class Hooman extends DataTransferObject { public string $name; }
You can instantiate this class like this :
$jane = new Hooman(name: 'Jane'); $john = new Hooman(['name' => 'John']);
Build complex DTO with Casting
An exemple of class with property with casting :
use Bluestone\DataTransferObject\DataTransferObject; use Bluestone\DataTransferObject\Attributes\CastWith; use Bluestone\DataTransferObject\Casters\ArrayCaster; class Hooman extends DataTransferObject { public string $name; #[CastWith(ArrayCaster::class, type: Hooman::class)] public array $children; }
You can instantiate this class like this :
$jane = new Hooman( name: 'Jane', children: [ new Hooman(name: 'Mario'), new Hooman(name: 'Luigi'), ], ); $john = new Hooman([ 'name' => 'John', 'children' => [ ['name' => 'Mario'], ['name' => 'Luigi'], ], ]);
Build complex DTO with Mapping
An exemple of class with property with mapping :
use Bluestone\DataTransferObject\DataTransferObject; use Bluestone\DataTransferObject\Attributes\Map; class Hooman extends DataTransferObject { #[Map('date_of_birth')] public string $bornAt; }
You can instantiate this class like this :
$jane = new Hooman( date_of_birth: '1970-01-01', ); $john = new Hooman([ 'date_of_birth' => '1970-01-01', ]);
Contributing
DTO is an open source project under MIT License and is open for contributions.
bluestone/dto 适用场景与选型建议
bluestone/dto 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.6k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「entity」 「dto」 「data-transfer-object」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bluestone/dto 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bluestone/dto 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bluestone/dto 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Data transfer objects with batteries included
Runn Me! Value Objects Library
PHP library for the MUMSYS project
A simple library that allows transform any kind of data to native php data or whatever
Data transfer objects with batteries included
generates php entities from openapi spec
统计信息
- 总下载量: 1.6k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-21