Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lalbert/silex-mongodb
Simple mongodb service provider for Silex 2.x and official mongodb driver
https://github.com/lalbert/silex-mongodb
mongodb silex-mongodb silex-provider silex2
Last synced: 8 days ago
JSON representation
Simple mongodb service provider for Silex 2.x and official mongodb driver
- Host: GitHub
- URL: https://github.com/lalbert/silex-mongodb
- Owner: lalbert
- License: mit
- Created: 2016-05-27T10:01:15.000Z (over 8 years ago)
- Default Branch: develop
- Last Pushed: 2016-05-27T16:00:59.000Z (over 8 years ago)
- Last Synced: 2024-04-02T03:04:16.904Z (8 months ago)
- Topics: mongodb, silex-mongodb, silex-provider, silex2
- Language: PHP
- Size: 6.84 KB
- Stars: 5
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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](http://php.net/manual/en/set.mongodb.php), **not [mongo](http://php.net/manual/en/book.mongo.php)**) and the official [MongoDB PHP driver](https://github.com/mongodb/mongo-php-library).
## Requirements
* PHP 5.4+
* [mongodb official PECL extension](https://secure.php.net/mongodb)## Installation
The best way to install the component is using [Composer](https://getcomposer.org/)
$ composer require lalbert/silex-mongodb
## Usage
### Register service
``` {.php}
$app->register(new MongoDBServiceProvider());
```You can also pass configuration settings :
_See http://php.net/manual/en/mongodb-driver-manager.construct.php for options allowed._
``` {.php}
$app->register(new MongoDBServiceProvider(), [
'mongodb.config' => [
'server' => 'mongodb://localhost:27017',
'options' => [],
'driverOptions' => [],
]
]);
```Your application :
``` {.php}
$document = ['key' => 'value'];$app['mongodb']
->mydatabase
->mycollection
->insert($document)
;
```_See official [MongoDB PHP Library documentation](http://mongodb.github.io/mongo-php-library/)_