moriony/silex-mongo-provider

Mongo service provider for the Silex framwork.

Installs: 5 707

Dependents: 1

Stars: 9

Watchers: 1

Forks: 2

Language: PHP

1.2.2 2014-03-09 08:05 UTC

README

Build Status Coverage Status Dependency Status

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));