Skip to content

Simple mongodb service provider for Silex 2.x and official mongodb driver

License

Notifications You must be signed in to change notification settings

lalbert/silex-mongodb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

silex-mongodb

Simple mongodb service provider for Silex 2.x and official mongodb driver

Features

This library provides easy access to a MongoDB database using the extension (mongodb, not mongo) and the official MongoDB PHP driver.

Requirements

Installation

The best way to install the component is using Composer

$ composer require lalbert/silex-mongodb

Usage

Register service

$app->register(new MongoDBServiceProvider());

You can also pass configuration settings :

See http://php.net/manual/en/mongodb-driver-manager.construct.php for options allowed.

$app->register(new MongoDBServiceProvider(), [
    'mongodb.config' => [
        'server' => 'mongodb://localhost:27017',
        'options' => [],
        'driverOptions' => [],
    ]
]);

Your application :

$document = ['key' => 'value'];

$app['mongodb']
  ->mydatabase
  ->mycollection
  ->insert($document)
;

See official MongoDB PHP Library documentation

About

Simple mongodb service provider for Silex 2.x and official mongodb driver

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages