moriony/silex-mongo-provider

Mongo service provider for the Silex framwork.

1.2.2 2014-03-09 08:05 UTC

This package is auto-updated.

Last update: 2024-10-25 19:34:44 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));