This package is abandoned and no longer maintained. No replacement package was suggested.

Silex Service Provider for MongoDB extension

v1.0.0 2014-02-13 17:21 UTC

This package is not auto-updated.

Last update: 2020-01-24 15:02:25 UTC



  • mongodb.server: (optional) Server to connect.
    Example: 'mongodb.server' => 'mongodb://,'

  • mongodb.options: Array of MongoDB options

  • db: DB name (required)

  • username: Authentication user

  • password: Authentication password

  • replicaSet: ReplicaSet name


Using multiple connections

You can use many MongoDB connections by registering the service provider multiple times with a different prefix passed to the constructor.

use LExpress\Silex\MongoDBServiceProvider;

$app->register(new MongoDBServiceProvider('mongodb.db1'), array(
    'mongodb.db1.options' => array(
        'db' => 'articles',
        'replicaSet' => 'rs1',

$app->register(new MongoDBServiceProvider('mongodb.db2'), array(
    'mongodb.db2.options' => array(
        'db' => 'users',
        'username' => 'bar',
        'password' => 'secret',

That will register 2 services: mongodb.db1 and mongodb.db2.