anhoder/swoft2-mongodb

swoft2-mongodb component for swoft2 framework

Fund package maintenance!
jenssegers
Tidelift

Installs: 62

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 0

Forks: 1 262

0.1.4 2020-12-07 05:39 UTC

This package is auto-updated.

Last update: 2021-09-20 12:54:52 UTC


README

针对Swoft2,基于jenssegers/laravel-mongodb进行改造的MongoDB包(不支持协程)。

Installation

Make sure you have the MongoDB PHP driver installed. You can find installation instructions at http://php.net/manual/en/mongodb.installation.php

Install the package via Composer:

$ composer require anhoder/swoft2-mongodb

Configuration

Add a new mongodb connection to app/bean.php:

return [
    // MongoDB
    'mongoDb'           => [
        'class'         => \Anhoder\Mongodb\Swoft\MongoDb::class,
        'host'          => '127.0.0.1',
        'port'          => 27017,
        'username'      => null,
        'password'      => null,
        'database'      => 'db1',
        'uriOptions'    => [],
        'driverOptions' => [],
    ],
    'mongodb.pool'      => [
        'class'       => \Anhoder\Mongodb\Swoft\MongoPool::class,
        'mongoDb'     => bean('mongoDb'),
        'minActive'   => 5,
        'maxActive'   => 10,
        'maxWait'     => 0,
        'maxWaitTime' => 0,
        'maxIdleTime' => 60,
    ],
];