moriony / silex-mongo-provider
Mongo service provider for the Silex framwork.
Installs: 8 488
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 2
Forks: 7
Open Issues: 2
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));