saxulum / saxulum-doctrine-mongodb-provider
该软件包已被 弃用 并不再维护。作者建议使用 chubbyphp / chubbyphp-laminas-config-doctrine 软件包代替。
Saxulum Doctrine MongoDB Provider
2.1.2
2019-05-29 05:54 UTC
Requires
- php: ~7.0|~5.6
- alcaeus/mongo-php-adapter: ^1.1.5
- doctrine/mongodb: ~1.1
- pimple/pimple: >=2.1,<4
- psr/log: ^1.1.0
Requires (Dev)
- phpunit/phpunit: ^5.7.27|^8.1.5
Provides
- ext-mongo: 1.6.14
README
与 plain silex-php 兼容
功能
- 支持 Silex 或 Cilex 中的 mongodb,但它不提供 ODM 集成
需求
- PHP 5.6+
- Doctrine Mongodb 1.0 Beta+
安装
通过 Composer 以 saxulum/saxulum-doctrine-mongodb-provider 的形式。
单个连接的示例
$app->register(new DoctrineMongoDbProvider(), array(
'mongodb.options' => array(
'server' => 'mongodb://localhost:27017',
'options' => array(
'username' => 'root',
'password' => 'root',
'db' => 'admin'
)
)
));
带自定义 ca 文件的单个连接示例
$app->register(new DoctrineMongoDbProvider(), array(
'mongodb.options' => array(
'server' => 'mongodb://localhost:27017',
'options' => array(
'username' => 'root',
'password' => 'root',
'db' => 'admin'
),
'driverOptions => array(
'ca_file' => '/some/ca.pem'
)
)
));
多个连接的示例
$app->register(new DoctrineMongoDbProvider(), array(
'mongodbs.options' => array(
'mongo1' => array(
'server' => 'mongodb://localhost:27017',
'options' => array(
'username' => 'root',
'password' => 'root',
'db' => 'admin'
)
),
'mongo2' => array(
'server' => 'mongodb://localhost:27018',
'options' => array(
'username' => 'root',
'password' => 'root',
'db' => 'admin'
)
)
)
));
使用
单个连接的示例
$document = array('key' => 'value');
$app['mongodb']
->selectDatabase('saxulum-doctrine-mongodb-provider')
->selectCollection('sample')
->insert($document)
;
多个连接的示例
$document = array('key' => 'value');
$app['mongodbs']['mongo1']
->selectDatabase('saxulum-doctrine-mongodb-provider')
->selectCollection('sample')
->insert($document)
;
版权
- Dominik Zogg [email protected]
- Fabien Potencier [email protected] (DoctrineServiceProvider,Logger)
- Kris Wallsmith [email protected] (Logger)