getme/mongodb-silex-provider

MongoDB provider for Silex

dev-master 2012-12-14 10:14 UTC

This package is not auto-updated.

Last update: 2024-11-09 14:40:04 UTC


README

Installation

Add to composer.json

"getme/mongodb-silex-provider": "dev-master"

Register

$app->register(new Sfk\Silex\Provider\MongoDBServiceProvider(), array(
    'mongodb.server' => 'mongodb://username:password@localhost:27017/mydatabase',
    'mongodb.options' => array(
    ),
));

Connection options explanation at http://php.net/manual/en/mongoclient.construct.php

Additional options:

  • mongodb.client_class - Base class name (default: \MongoClient) see example below.
class  MyMongoClient extends \MongoClient {
    // some useful methods
}

$app->register(new Sfk\Silex\Provider\MongoDBServiceProvider(), array(
    // as above
    'mongodb.client_class' => 'MyMongoClient'
));