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

  1. 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.
  2. Install MongoDB using the correct installation process from https://docs.mongodb.org/manual/installation/ for your system.
  3. Install the php5-mongo PHP extension.
  4. Install the component with the following command:
    composer require yiisoft/yii2-mongodb
    

How to do it…

  1. First of all, create the new MongoDB database. Run it in the mongo-client shell and type the database name:
    mongo
    > use mydatabase
    
  2. Add this connection information ...

Get Yii2 Application Development Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.