emreuyguc/structured-mapper
Composer 安装命令:
composer require emreuyguc/structured-mapper
包简介
Structured Mapper is a PHP library that helps you to map your objects, such as entities to DTOs or models to entities, easily.
关键字:
README 文档
README
Euu Structured Mapper is a simple and experimental data transformation library for PHP.
This project aims to simplify defining transformation rules using attributes and performing data type conversions. It also provides an extremely simple structure for ease of use.
Features
- Attribute-Based Mapping Definition: Ability to define transformation rules using attributes.
- mapFrom and mapTo Transformation Definitions: Define transformation rules on either the source or target class.
- Direct Property Definitions: Define transformations directly on properties.
- Context Passing and Usage: Pass contextual information during mapping.
- Value Transformers: Perform type and data transformations using value transformer structures.
- Important Transformers: Predefined transformers for common use cases like Doctrine Entities, Enums, Array items, etc.
- Structure Read and Storage Mechanism: Extendable structure reader to read transformation definitions from different sources.
- Custom Mapper Definitions: Define custom transformation classes (see
MapperRegistryandMapperInterface). - Array Item Transformations: Transform array elements and process each element with a value transformer (see
ValueTransformer/ArrayItemTransform/ArrayItemTransformer.php). - Sub-Object Transformations: Define transformations for child objects (see
ValueTransformer/ObjectTransform/WithMapper.php).
Installation
Add Euu Structured Mapper to your project using Composer:
composer require emreuyguc/structured-mapper
Usage
For detailed examples, refer to the example/ExampleFactory.php file. Initialize the mapper according to your own usage scenarios.
Examples
example/MapFromExample.phpexample/MapToExample.phpexample/Dto/example/Entity/
Limitations and Considerations
- Object Constructor Issue: Objects with constructors cannot be initialized during transformations. This area is open for improvement (Priority: High).
- Reverse Transformation: If
a -> btransformations are defined, reverse (b -> a) is theoretically possible but not currently supported (Priority: Medium). - Type Conversion Mechanism: There is no general mechanism for type conversions. Users must handle this manually or set the
type_enforcementparameter tofalsefor simple conversions (Priority: Low). - Property Naming: Property names must be defined manually during mapping. An automatic name conversion mechanism can be added (Priority: Medium).
- Cache Mechanism: Currently, there is no caching mechanism. A suitable cache structure can be implemented (Priority: High).
- Mapping Check: A
canMapmethod can be added for checking mappings (Priority: High). - Auto Sub-Type Mapping: Automatically map child objects based on their types (Priority: Medium).
- Custom Mapper Transformation Type Check: Ensure that custom mapper definitions validate source and destination types. This check is currently missing (Priority: High).
- Expression Usage in Entity Find Function: Use expression language for custom parameters in entity transformations (Priority: Low).
- Tests: Write tests (Priority: High).
License
This package is licensed under the MIT License.
emreuyguc/structured-mapper 适用场景与选型建议
emreuyguc/structured-mapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 25 次下载、GitHub Stars 达 3, 最近一次更新时间为 2025 年 01 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「mapping」 「mapper」 「entity-mapper」 「dto」 「transformation」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 emreuyguc/structured-mapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 emreuyguc/structured-mapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 emreuyguc/structured-mapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
data-mapper php library
Convention-based Alternative ORM
Forms mapping of Doctrine ORM entities for Nette Framework
a library to simplify handling(filter, map, ...) collections in php
Laravel SDK mapping data in object
DCSDynamicDiscriminatorMapBundle simplifies the use of Doctrine Single Table Inheritance mapping strategy in Symfony2.
统计信息
- 总下载量: 25
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-01-05