Skip to content

TheLuckyOne/silex-mongo-provider

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

silex-mongo-provider

Build Status Coverage Status Dependency Status

Mongo service provider for the Silex framework. Tested this PHP7 & last MongoDB driver.

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

About

Mongo service provider for the Silex framwork.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%