shandy-dev/humus-doctrine-hydrator
Composer 安装命令:
composer require shandy-dev/humus-doctrine-hydrator
包简介
Humus Doctrine (recursive) Hydrator
README 文档
README
Humus Doctrine Hydrator
A Hydrator implementing Zend\Stdlib\Hydrator\HydratorInterface, completely based on Doctrine\Common
- can return cloned object
- let's you control what field should be extracted (recursively)
- can flat single keys
Requirements
Installation
- Add
"prolic/humus-doctrine-hydrator": "dev-master"to yourcomposer.json - Run
php composer.phar install
Example
Let's assume you want to hydrate an array to an object, and then you want to extract all it's internals
Example Class: "User", has relationships to his "Locale", "Language" and "Address". The address entity has also a relation to "Country".
$hydrator = new \Humus\Doctrine\Hydrator\Hydrator( $context->get('EntityManager'), // the entity manager true, // yes, we want a cloned object, not the original one array( 'id', 'name', 'firstname', 'fax', 'email', 'gender', 'locale' => array( 'name' ), 'preferred_contact_type' => array( 'id' ), 'address' => array( 'street', 'zip', 'city', 'country' => array( 'id', 'name' ), ), 'spoken_languages' => array( 'id', ), ), // we describe, what should be returned by extract, otherwise it could be that // a) We dump the Unit of Work // b) We dump half of the database false //do not flat single keys ); // we got some data $data = array( 'id' => 5, ); // we get the cloned address object, // just switch the clone argument in constructor to false, in order to get the real object back $address = $hydrator->hydrate($data, new \Application\Entity\Contact()); $result = $hydrator->extract($address); var_dump($result); // output: array(6) { ["id"]=> int(5) ["gender"]=> string(4) "male" ["name"]=> string(20) "Sascha-Oliver Prolic" ["locale"]=> array(1) { ["name"]=> string(10) "Deutsch DE" } ["address"]=> array(4) { ["street"]=> string(13) "Sample Street" ["zip"]=> string(5) "00000" ["city"]=> string(6) "Berlin" ["country"]=> array(2) { ["id"]=> int(1) ["name"]=> string(7) "Germany" } } ["spoken_languages"]=> array(1) { [0]=> array(1) { ["id"]=> int(1) } } } // Please note how the output changes (watch for locale) when you switch the "flatSingleKeys" flag to true // in the constructor of the hydrator
shandy-dev/humus-doctrine-hydrator 适用场景与选型建议
shandy-dev/humus-doctrine-hydrator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 95 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 10 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「zf2」 「doctrine」 「humus」 「hydrator」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 shandy-dev/humus-doctrine-hydrator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shandy-dev/humus-doctrine-hydrator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 shandy-dev/humus-doctrine-hydrator 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP-AMQP library with RabbitMQ Extensions
AMQP module for Zend Framework 2 to integrate RabbitMQ
LosLog provides some log utility
HumusAmqp Producer for Prooph Service Bus
EdpModuleLayouts is very simple Laminas module for making module-specific layouts insanely easy.
Zend Framework module to leverage the symfony dependency injection container
统计信息
- 总下载量: 95
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-10-27