joorloohuis/yii2-mongodb 问题修复 & 功能扩展

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

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

joorloohuis/yii2-mongodb

最新稳定版本:v2.0.1

Composer 安装命令:

composer require joorloohuis/yii2-mongodb

包简介

Yii2 component that provides a wrapper for the official mongodb.org client

README 文档

README

MongoClient exposes official MongoDB support as provided by mongodb.org in the form of a Yii2 component. This component provides a MongoDB\Client object, and as such may be used exactly as documented in the official MongoDB referece.

The reason behind the existence of this component is that the standard Yii2 component caters to the AR approach, and this shields a lot of the powerful core functionality provided by the MongoDB PHP Library provided by mongodb.org.

This component requires the newer mongodb PHP extension, the old mongo PHP extension is untested and unsupported.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require joorloohuis/yii2-mongodb

or add

"joorloohuis/yii2-mongodb": "^1.0.0"

to the require section of your composer.json file.

Configuration

Add the following section to the components part of your configuration:

<?php
    'mongoclient' => [
        'class' => \joorloohuis\mongodb\components\MongoClient::class,
        'dsn' => 'mongodb://mongouser:mongopw@localhost:27017/database?args',
        // alternatively, provide separate parameters
        // 'host' => 'localhost',
        // 'port' => 27017,
        // 'user' => 'mongouser',
        // 'password' => 'mongopw',
        // 'db' => 'mongodatabase',
        // 'args' => 'args',
    ];

Usage

The MongoClient can be used for any operations the MongoDB PHP Library supports, for example:

$collection = \Yii::$app->mongoclient->database->selectCollection('mycollection');
$cursor = $collection->aggregate([
    // aggregation pipeline parts go here
]);
$result = $cursor->toArray();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-02-28