PHP code example of anhoder / swoft2-mongodb

1. Go to this page and download the library: Download anhoder/swoft2-mongodb library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

anhoder / swoft2-mongodb example snippets


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,
    ],
];