saxulum / saxulum-doctrine-mongodb-provider
Saxulum Doctrine MongoDB Provider
Installs: 194 370
Dependents: 2
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 3
Open Issues: 1
Requires
- php: ~7.0|~5.6
- alcaeus/mongo-php-adapter: ^1.1.5
- doctrine/mongodb: ~1.1
- pimple/pimple: >=2.1,<4
- psr/log: ^1.1.0
Requires (Dev)
- phpunit/phpunit: ^5.7.27|^8.1.5
Provides
- ext-mongo: 1.6.14
README
works with plain silex-php
Features
Requirements
- PHP 5.6+
- 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 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'
)
)
)
));
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
- Dominik Zogg dominik.zogg@gmail.com
- Fabien Potencier fabien@symfony.com (DoctrineServiceProvider, Logger)
- Kris Wallsmith kris@symfony.com (Logger)