saxulum/saxulum-doctrine-mongodb-provider

This package is abandoned and no longer maintained. The author suggests using the chubbyphp / chubbyphp-laminas-config-doctrine package instead.

Saxulum Doctrine MongoDB Provider

2.1.2 2019-05-29 05:54 UTC

This package is auto-updated.

Last update: 2021-10-02 20:02:09 UTC


README

works with plain silex-php

Build Status Total Downloads Latest Stable Version

Features

  • Support for mongodb within Silex or Cilex, it does NOT PROVIDE the ODM integration

Requirements

  • PHP 5.6+
  • Doctrine Mongodb 1.0 Beta+

Installation

Through Composer as saxulum/saxulum-doctrine-mongodb-provider.

Example for one connection:

$app->register(new DoctrineMongoDbProvider(), array(
    'mongodb.options' => array(
        'server' => 'mongodb://localhost:27017',
        'options' => array(
            'username' => 'root',
            'password' => 'root',
            'db' => 'admin'
        )
    )
));

Example for one connection with custom ca file:

$app->register(new DoctrineMongoDbProvider(), array(
    'mongodb.options' => array(
        'server' => 'mongodb://localhost:27017',
        'options' => array(
            'username' => 'root',
            'password' => 'root',
            'db' => 'admin'
        ),
        'driverOptions => array(
            'ca_file' => '/some/ca.pem'
        )
    )
));

Example for multiple connections:

$app->register(new DoctrineMongoDbProvider(), array(
    'mongodbs.options' => array(
        'mongo1' => array(
            'server' => 'mongodb://localhost:27017',
            'options' => array(
                'username' => 'root',
                'password' => 'root',
                'db' => 'admin'
            )
        ),
        'mongo2' => array(
            'server' => 'mongodb://localhost:27018',
            'options' => array(
                'username' => 'root',
                'password' => 'root',
                'db' => 'admin'
            )
        )
    )
));

Usage

Example for one connection:

$document = array('key' => 'value');

$app['mongodb']
    ->selectDatabase('saxulum-doctrine-mongodb-provider')
    ->selectCollection('sample')
    ->insert($document)
;

Example for multiple connections:

$document = array('key' => 'value');

$app['mongodbs']['mongo1']
    ->selectDatabase('saxulum-doctrine-mongodb-provider')
    ->selectCollection('sample')
    ->insert($document)
;

Copyright