emreuyguc/structured-mapper 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

PHP Version License Author

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 MapperRegistry and MapperInterface).
  • 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.php
  • example/MapToExample.php
  • example/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 -> b transformations 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_enforcement parameter to false for 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 canMap method 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 emreuyguc/structured-mapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 25
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 20
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-05