matryoshka-model/mongo-wrapper
Composer 安装命令:
composer require matryoshka-model/mongo-wrapper
包简介
MongoDB matryoshka wrapper
README 文档
README
Matryoshka wrapper for MongoDB ------------------------------Use MongoDB as data gateway for Matryoshka.
Community
For questions and support please visit the slack channel (get an invite here).
Installation
Install it using composer.
Add the following to your composer.json file:
"require": {
"matryoshka-model/mongo-wrapper": "~0.8.0"
}
Configuration
This library provides two abstract factories for Zend\ServiceManager to make MongoDb and MongoCollection available as services. In order to use them in a ZF2 application, register the provided factories through the service_manager configuration node:
'service_manager' => [ 'abstract_factories' => [ 'Matryoshka\Model\Wrapper\Mongo\Service\MongoDbAbstractServiceFactory', 'Matryoshka\Model\Wrapper\Mongo\Service\MongoCollectionAbstractServiceFactory', ], ],
Then in your configuration you can add the mongodb and mongocollection nodes and configure them as in example:
'mongodb' => [ 'Application\MongoDb\YourDatabaseName' => [ 'hosts' => '127.0.0.1:27017', 'database' => 'yourDatabaseName' ], ... ], 'mongocollection' => [ 'Application\DataGateway\YourCollectionName' => [ 'database' => 'Application\MongoDb\YourDatabaseName', 'collection' => 'yourCollectionName' ], ... ],
Usage
This wrapper provides extensions and default implementations for using MongoCollection as a datagateway.
Main concepts:
-
Inject a
Matryoshka\Model\Wrapper\Mongo\Criteria\ActiveRecordCriteriainstance into yourMatryoshka\Model\Object\AbstractActiveRecordobjectsThis way the matryoshka Active Record implementation will work with your MongoDB collections
-
Matryoshka\Model\Wrapper\Mongo\PaginatorMongoPaginatorAdapteris a paginator adapter that can be used within paginable criterias -
Matryoshka\Model\Wrapper\Mongo\ResultSetHydratingResultSetmakes the counting functionality working correctly withMongoCursordatasources
NOTES
It's important to always use the HydratingResultSet class included in this package because MongoCursor does not implement the Countable and MongoCursor::count() must be called passing true as parameter.
Components
-
Matryoshka\Model\Wrapper\Mongo\Criteriadirectory contains the aforementionedActiveRecordCriteriamatryoshka criteria. -
Matryoshka\Model\Wrapper\Mongo\Hydratordirectory contains-
ClassMethods, an hydrator that can be used with matryoshka objects when you have MongoDB collections as datagateways -
NamingStrategy\DefaultNamingStrategyandNamingStrategy\UnderscoreNamingStrategy, two strategies that can be overridden to setup the naming rules map of your fields. By default, both convert_idtoid. -
Strategy\*, some common strategies for MongoDB.
-
-
Matryoshka\Model\Wrapper\Mongo\Paginatordirectory contains the aforementionedMongoPaginatorAdapteradapter. -
Matryoshka\Model\Wrapper\Mongo\ResultSetcontains the aforementionedHydratingResultSetwhich extends matryoshka'sHydratingResultSetto make theMongoCursorcounting functionality working properly. -
Matryoshka\Model\Wrapper\Mongo\Servicecontains abstract service factories generally aimed at instantiation of\MongoCollectionand\MongoDbobjects. Usemongocollectionandmongodbconfiguration nodes to respectively setup them (see above).
Continuous integration
CI provided through TravisCI.
This wrapper is tested against the following MongoDB PHP clients: 1.4.5, 1.5.0, 1.5.1, 1.5.2, 1.5.3, 1.5.3, 1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.6.0, 1.6.1, 1.6.2, 1.6.3, 1.6.4, 1.6.5, 1.6.6, 1.6.7, 1.6.8, 1.6.9, 1.6.10, 1.6.11, 1.6.12, 1.6.13.
matryoshka-model/mongo-wrapper 适用场景与选型建议
matryoshka-model/mongo-wrapper 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.05k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2014 年 09 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「nosql」 「mongodb」 「db」 「mvc」 「mongo」 「model」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 matryoshka-model/mongo-wrapper 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 matryoshka-model/mongo-wrapper 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 matryoshka-model/mongo-wrapper 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Generates Symfony2 documents, forms and CRUD
The DreamFactory(tm) CouchDB Service.
Kinikit - PHP Application development framework MVC component
The CodeIgniter Redis package
Symfony lock Tarantool store
A package to allow laravel/passport use with mongodb/laravel-mongodb
统计信息
- 总下载量: 1.05k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 31
- 推荐数: 3
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2014-09-11
