MongoDB driver
This extension provides the MongoDB integration for the Yii2 framework and allows you to work with MongoDB collection's records via the ActiveRecord-style
model.
Getting ready
Create a new application by using composer, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Install MongoDB using the correct installation process from https://docs.mongodb.org/manual/installation/ for your system.
Install the
php5-mongo
PHP extension.Install the component with the following command:
composer require yiisoft/yii2-mongodb
How to do it…
First of all, create the new MongoDB database. Run it in the
mongo-client
shell and type the database name:mongo > use mydatabase
Add this connection information to your
components
config section:return [ // ... 'components' => [ // ... 'mongodb' => [ 'class' => '\yii\mongodb\Connection', 'dsn' => 'mongodb://localhost:27017...