MongoDB service provider for the Silex 2 framework. Tested with PHP7 and the MongoDB library.
- PHP 5.6 or PHP 7
- PHP MongoDB driver
- MongoDB PHP Library
Add the required entry for this library to your composer.json
.
{
"require": {
"xatoo/silex2-mongodb-provider": "*"
}
}
and run composer install
(or update
) to download all files.
$app->register(new MongoDBServiceProvider, [
'mongodb.configuration' => [
'default' => [
'server' => "mongodb://localhost:27017",
'options' => ["connect" => true]
]
],
]);
$connections = $app['mongodb'];
$defaultConnection = $connections['default'];
$mongoFactory = $app['mongodb.factory'];
$customConnection = $mongoFactory("mongodb://localhost:27017", ["connect" => true]);
- Sander Toonen s.toonen@gmail.com