PHP code example of phpmongokit / yii2-mongo-odm
1. Go to this page and download the library: Download phpmongokit/yii2-mongo-odm library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phpmongokit / yii2-mongo-odm example snippets
return array(
'components' => array(
// configure mongo service
'mongo' => array(
'class' => 'PHPMongoKit\ODM\Adapter\Yii2\Client',
'dsn' => 'mongodb://127.0.0.1',
'options' => array(
'connect' => true,
'readPreference' => \MongoClient::RP_SECONDARY_PREFERRED,
),
'defaultDatabase' => 'database_name',
'map' => array(
'database_name' => array(
'collectionName1' => '\Collection\Class1',
'collectionName2' => '\Collection\Class2',
)
)
),
)
);
composer