xatoo/silex2-mongodb-provider

This package is abandoned and no longer maintained. No replacement package was suggested.

MongoDB service provider for the Silex 2 framework.

0.0.1 2016-06-17 19:37 UTC

This package is not auto-updated.

Last update: 2019-10-14 14:41:57 UTC


README

Build Status Coverage Status Dependency Status StyleCI SensioLabsInsight Latest Stable Version Total Downloads License

MongoDB service provider for the Silex 2 framework. Tested with PHP7 and the MongoDB library.

Requirements

Installation

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.

Usage

Service registration

$app->register(new MongoDBServiceProvider, [
    'mongodb.configuration' => [
        'default' => [
            'server' => "mongodb://localhost:27017",
            'options' => ["connect" => true]
        ]
    ],
]);

Connections retrieving

$connections = $app['mongodb'];
$defaultConnection = $connections['default'];

Creating a mongo connection via the factory

$mongoFactory = $app['mongodb.factory'];
$customConnection = $mongoFactory("mongodb://localhost:27017", ["connect" => true]);

Copyright