<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
devture / silex-provider-doctrine-mongodb example snippets
// Register services under the 'mongodb' namespace, with no custom configuration (empty array)
$app->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');
};
// See the docs for \MongoClient (http://php.net/MongoClient) for connection string format and options
$configuration = [
'server' => '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');
};
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.