lexpress / mongodb-service-provider
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
Requires
- ext-mongo: >=1.3.0
- silex/silex: ~1.0
This package is not auto-updated.
Last update: 2020-01-24 15:02:25 UTC
README
Parameters
-
mongodb.server: (optional) Server to connect.
Example:'mongodb.server' => 'mongodb://127.0.0.1:27017,127.0.0.1:27018'
-
mongodb.options: Array of MongoDB options
-
db: DB name (required)
-
username: Authentication user
-
password: Authentication password
-
replicaSet: ReplicaSet name
Services
- mongodb: Instance of
MongoDB
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
.