Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/spantaleev/silex-provider-doctrine-mongodb
Silex provider for MongoDB integration via Doctrine
https://github.com/spantaleev/silex-provider-doctrine-mongodb
Last synced: about 1 month ago
JSON representation
Silex provider for MongoDB integration via Doctrine
- Host: GitHub
- URL: https://github.com/spantaleev/silex-provider-doctrine-mongodb
- Owner: spantaleev
- License: bsd-3-clause
- Created: 2013-02-23T16:33:51.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2021-12-07T06:52:46.000Z (about 3 years ago)
- Last Synced: 2024-11-14T22:43:23.506Z (about 2 months ago)
- Language: PHP
- Size: 3.91 KB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Silex Doctrine-MongoDB Provider
A [doctrine/mongodb](https://github.com/doctrine/mongodb) provider for the [Silex](https://github.com/silexphp/Silex) micro-framework.
## Usage
Registering the provider creates a few services under a given *namespace*.
The provider can be registered multiple times if multiple connections are needed.### Basic Usage
```php
register(new \Devture\SilexProvider\DoctrineMongoDB\ServicesProvider('mongodb', []));// Get a reference to a database on that server connection
$app['db'] = function ($app) {
return $app['mongodb.connection']->selectDatabase('database_name');
};
```### Advanced Usage
```php
'mongodb://example.com:27017',
'options' => [
'connect' => true,
'connectTimeoutMS' => 200,
],
];$app->register(new \Devture\SilexProvider\DoctrineMongoDB\ServicesProvider('mongodb', $configuration));
$app['db_main'] = function ($app) {
return $app['mongodb.connection']->selectDatabase('database_name');
};$app['db_other'] = function ($app) {
return $app['mongodb.connection']->selectDatabase('another_database_name');
};
```