phpmongokit / yii2-mongo-odm
PHPMongo Yii2 Adapter
Installs: 1 602
Dependents: 0
Suggesters: 3
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 2
Requires
- sokil/php-mongo: 1.*
This package is auto-updated.
Last update: 2024-10-28 02:12:22 UTC
README
Yii Adapter for PHPMongo ORM
Requirements
- PHP 5
- PHP 5.3 - PHP 5.6
- PHP Mongo Extension 0.9 or above (Some features require >= 1.5)
- PHP 7 and HHVM
- PHP MongoDB Extension 1.0 or above
- Compatibility layer. Please, note some restriontions
- HHVM Driver not supported.
- Tested over MongoDB v.2.4.12, v.2.6.9, v.3.0.2, v.3.2.10, v.3.3.15, v.3.4.0. See Unit tests for details
Installation
You can install library through Composer:
composer require phpmongokit/yii2-mongo-odm
Compatibility with PHP 7
PHPMongo currently based on old ext-mongo entension. To use this ODM with PHP 7, you need to add compatibility layer, which implement API of old extension over new ext-mongodb. To start using PHPMongo with PHP7, add requirement alcaeus/mongo-php-adapter to composer. Restrictions for using ODM with compatibility layer you can read in known issues of original adapter.
Add adapter of old ext-mongo
API to new ext-mongodb
:
composer require alcaeus/mongo-php-adapter
Configuration of Client
<?php 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', ) ) ), ) );