将 yii2 与 mongodb 连接 [英] Connect yii2 with mongodb
问题描述
我是 Yii2 的新手.谁能告诉我如何用 mongodb 配置 YII2 以及如何在 YII2 和 mongodb 之间建立连接?我尝试从 git hub 下载 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 "*"
在我安装 Yii2 的根文件夹内的命令提示符中,但出现以下错误
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].
推荐答案
如果您尝试通过命令提示符安装它,请尝试使用 Composer 的以下命令
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 "*"
这适用于我的 Windows 8 环境.
This works in my windows 8 environment.
要在安装包时忽略依赖项错误,请使用 --ignore-platform-refs
开关:
To ignore dependency errors while installing the package use --ignore-platform-refs
switch:
composer require --ignore-platform-refs --prefer-dist yiisoft/yii2-mongodb "*"
这篇关于将 yii2 与 mongodb 连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!