Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect yii2 with mongodb

I am new to Yii2. Can anyone tell me how to configure YII2 with mongodb and how to establish connection between YII2 and mongodb? I have tried to download the mongodb package from git hub and tried to run the following command

php composer.phar require --prefer-dist yiisoft/yii2-mongodb "*"

In the command prompt inside the root folder where I have installed Yii2 but I get the following error

 Your requirements could not be resolved to an installable set of packages.
 Problem 1
- yiisoft/yii2 2.0.0 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching      package found.
- yiisoft/yii2 2.0.0 requires bower-asset/jquery 2.1.*@stable | 1.11.*@stable -> no matching package found.
- Installation request for yiisoft/yii2 == 2.0.0.0 -> satisfiable by yiisoft/yii2[2.0.0].
like image 230
Ashwin Avatar asked Sep 29 '22 06:09

Ashwin


2 Answers

If you are trying to install it through command prompt then try the following command which using composer

composer require --prefer-dist yiisoft/yii2-mongodb "*"

This works in my windows 8 environment.

To ignore dependency errors while installing the package use --ignore-platform-refs switch:

composer require --ignore-platform-refs --prefer-dist yiisoft/yii2-mongodb "*"
like image 129
Shaggie Avatar answered Oct 04 '22 03:10

Shaggie


Remember that you must also have the MongoDB extension installed in PHP for this plugin to work:

http://php.net/manual/en/class.mongodb.php

like image 40
Alex Avatar answered Oct 04 '22 04:10

Alex