saxulum/saxulum-doctrine-mongodb-provider

Saxulum Doctrine MongoDB Provider

Installs: 5 591

Dependents: 2

Stars: 1

Watchers: 1

Open Issues: 1

Language: PHP

2.0.0 2014-10-04 09:15 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.3+
  • 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 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