MongoDb Extension for Yii 2 ¶
This extension provides the MongoDB integration for the Yii framework 2.0.
For license information check the LICENSE-file.
Installation ¶
This extension requires MongoDB PHP Extension version 1.5.0 or higher.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yiisoft/yii2-mongodb
or add
"yiisoft/yii2-mongodb": "~2.0.0"
to the require section of your composer.json.
Configuration ¶
To use this extension, simply add the following code in your application configuration:
return [
//....
'components' => [
'mongodb' => [
'class' => '\yii\mongodb\Connection',
'dsn' => 'mongodb://developer:password@localhost:27017/mydatabase',
],
],
];
Class Reference
Class | Description |
---|---|
yii\mongodb\ActiveFixture | ActiveFixture represents a fixture backed up by a MongoDB ActiveRecord class or a MongoDB collection. |
yii\mongodb\ActiveQuery | ActiveQuery represents a Mongo query associated with an Active Record class. |
yii\mongodb\ActiveRecord | ActiveRecord is the base class for classes representing Mongo documents in terms of objects. |
yii\mongodb\Cache | Cache implements a cache application component by storing cached data in a MongoDB. |
yii\mongodb\Collection | Collection represents the Mongo collection information. |
yii\mongodb\Connection | Connection represents a connection to a MongoDb server. |
yii\mongodb\Database | Database represents the Mongo database information. |
yii\mongodb\Exception | Exception represents an exception that is caused by some Mongo-related operations. |
yii\mongodb\Migration | Migration is the base class for representing a MongoDB migration. |
yii\mongodb\Query | Query represents Mongo "find" operation. |
yii\mongodb\Session | Session extends yii\web\Session by using MongoDB as session data storage. |
yii\mongodb\console\controllers\MigrateController | Manages application MongoDB migrations. |
yii\mongodb\debug\MongoDbPanel | MongoDbPanel panel that collects and displays MongoDB queries performed. |
yii\mongodb\file\ActiveQuery | ActiveQuery represents a Mongo query associated with an file Active Record class. |
yii\mongodb\file\ActiveRecord | ActiveRecord is the base class for classes representing Mongo GridFS files in terms of objects. |
yii\mongodb\file\Collection | Collection represents the Mongo GridFS collection information. |
yii\mongodb\file\Query | Query represents Mongo "find" operation for GridFS collection. |
yii\mongodb\gii\model\Generator | This generator will generate ActiveRecord class for the specified MongoDB collection. |
yii\mongodb\log\MongoDbTarget | MongoDbTarget stores log messages in a MongoDB collection. |
yii\mongodb\validators\MongoDateValidator | MongoDateValidator is an enhanced version of yii\validators\DateValidator, which supports \MongoDate values. |
yii\mongodb\validators\MongoIdValidator | MongoIdValidator verifies if the attribute is a valid Mongo ID. |