df / silex-doctrine-mongodb-provider
Silex Doctrine MongoDB Provider
Installs: 4 845
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^5.5 || ^7.0
- alcaeus/mongo-php-adapter: 1.0.5
- doctrine/mongodb: ^1.3.0
- mongodb/mongodb: ^1.0.2
- pimple/pimple: ~3.0
- psr/log: 1.0.*
Requires (Dev)
- phpunit/phpunit: ^4.8
- silex/silex: ^2.0.2
Provides
- ext-mongo: 1.6.13
This package is not auto-updated.
Last update: 2024-11-23 20:47:45 UTC
README
Just another Silex service provider for mongodb, based on Dominik Zogg dominik.zogg@gmail.com great repository saxulum-doctrine-mongodb-provider containing some improvements and refactoring to gain compatibility for silex 2.n/pimple 3.n and PHP 7.n
Features
- Support for MongoDB inside Silex (it does NOT PROVIDE the ODM integration)
- Support for PHP7 using "alcaeus/mongo-php-adapter" as wrapper for deprecated ext-mongo module
- ODM integration will provide by df/silex-doctrine-mongodb-odm-provider (take a look)
Requirements
- PHP >= 5.5.n
- Silex 2.n (pimple 3.n)
- Doctrine MongoDb (>= 1.3.0)
Installation
Using composer df/silex-doctrine-mongodb-provider.
composer require df/silex-doctrine-mongodb-provider
Setup
- Example for one connection:
$app->register(new DoctrineMongoDbProvider(), [
'mongodb.options' => [
'server' => 'mongodb://localhost:27017',
'options' => [
'username' => 'your-username',
'password' => 'your-password',
'db' => 'mongo_db_01'
]
]
]);
- Example for multiple connections:
$app->register(new DoctrineMongoDbProvider(), [
'mongodbs.options' => [
'mongodb1' => [
'server' => 'mongodb://localhost:27017',
'options' => [
'username' => 'your-username',
'password' => 'your-username',
'db' => 'mongo_db_01'
]
],
'mongodb2' => [
'server' => 'mongodb://localhost:27018',
'options' => [
'username' => 'your-username',
'password' => 'your-username',
'db' => 'mongo_db_02'
]
]
]
));
Usage
- Example for one connection:
$document = ['key' => 'value'];
$app['mongodb']
->selectDatabase('mongo_db_01')
->selectCollection('sample')
->insert($document)
;
- Example for multiple connections:
$document = ['key' => 'value'];
$app['mongodbs']['mongo1']
->selectDatabase('mongo_db_01')
->selectCollection('sample')
->insert($document)
;
Copyright
- Patrick Paechnatz patrick.paechnatz@gmail.com
- Dominik Zogg dominik.zogg@gmail.com (the origin service provider author)
- Fabien Potencier fabien@symfony.com (DoctrineServiceProvider, Logger)
- Kris Wallsmith kris@symfony.com (Logger)