moriony / silex-mongo-provider
Mongo service provider for the Silex framwork.
1.2.2
2014-03-09 08:05 UTC
Requires
- pimple/pimple: *
- silex/silex: 1.*
Requires (Dev)
- phpunit/phpunit: 3.7.*
- satooshi/php-coveralls: *
README
Mongo service provider for the Silex framwork.
Install via composer
Add in your composer.json the require entry for this library.
{
"require": {
"moriony/silex-mongo-provider": "*"
}
}
and run composer install (or update) to download all files.
Usage
Service registration
$app->register(new MongoServiceProvider, array( 'mongo.connections' => array( 'default' => array( 'server' => "mongodb://localhost:27017", 'options' => array("connect" => true) ) ), ));
Connections retrieving
$connections = $app['mongo']; $defaultConnection = $connections['default'];
Creating mongo connection via factory
$mongoFactory = $app['mongo.factory']; $customConnection = $mongoFactory("mongodb://localhost:27017", array("connect" => true));