works with plain silex-php
- PHP 5.6+
- Doctrine Mongodb 1.0 Beta+
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'
)
)
)
));
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)
;
- Dominik Zogg [email protected]
- Fabien Potencier [email protected] (DoctrineServiceProvider, Logger)
- Kris Wallsmith [email protected] (Logger)