为 php 安装 MongoDB 驱动程序出错(Windows)

Posted

技术标签:

【中文标题】为 php 安装 MongoDB 驱动程序出错(Windows)【英文标题】:Installing MongoDB Driver for php gone wrong (windows) 【发布时间】:2021-01-11 14:18:22 【问题描述】:

我已按照以下链接中的说明进行操作:

https://www.php.net/manual/en/mongodb.installation.windows.php

但是当我尝试以下命令之一时:

composer require jenssegers/mongodb

composer require jenssegers/mongodb:dev-develop

composer require jenssegers/mongodb --ignore-platform-reqs

它们都返回相同的错误:

 Using version ^3.7 for jenssegers/mongodb
 ./composer.json has been updated
 Loading composer repositories with package information
 Updating dependencies (including require-dev)
 Your requirements could not be resolved to an installable set of packages.

Problem 1
- Conclusion: don't install jenssegers/mongodb v3.7.0
- Installation request for jenssegers/mongodb ^3.7 -> satisfiable by jenssegers/mongodb[3.7.x-dev, v3.7.0].
- Conclusion: don't install laravel/framework v5.6.38
- jenssegers/mongodb 3.7.x-dev requires illuminate/events ^7.0 -> satisfiable by illuminate/events[7.x-dev, v7.0.0, v7.0.1, v7.0.2, v7.0.3, v7.0.4, v7.0.5, v7.0.6, v7.0.7, v7.0.8, v7.1.0, v7.1.1, v7.1.2, v7.1.3, v7.10.0, v7.10.1, v7.10.2, v7.10.3, v7.11.0, v7.12.0, v7.13.0, v7.14.0, v7.14.1, v7.15.0, v7.16.0, v7.16.1, v7.17.0, v7.17.1, v7.17.2, v7.18.0, v7.19.0, v7.19.1, v7.2.0, v7.2.1, v7.2.2, v7.20.0, v7.21.0, v7.22.0, v7.22.1, v7.22.2, v7.22.3, v7.22.4, v7.23.0, v7.23.1, v7.23.2, v7.24.0, v7.25.0, v7.26.0, v7.26.1, v7.27.0, v7.28.0, v7.28.1, v7.28.2, v7.28.3, v7.3.0, v7.4.0, v7.5.0, v7.5.1, v7.5.2, v7.6.0, v7.6.1, v7.6.2, v7.7.0, v7.7.1, v7.8.0, v7.8.1, v7.9.0, v7.9.1, v7.9.2].
- don't install illuminate/events 7.x-dev|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.3|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.4|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.5|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.6|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.7|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.0.8|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.1.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.1.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.1.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.1.3|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.10.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.10.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.10.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.10.3|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.11.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.12.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.13.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.14.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.14.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.15.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.16.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.16.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.17.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.17.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.17.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.18.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.19.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.19.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.2.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.2.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.2.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.20.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.21.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.22.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.22.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.22.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.22.3|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.22.4|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.23.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.23.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.23.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.24.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.25.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.26.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.26.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.27.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.28.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.28.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.28.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.28.3|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.3.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.4.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.5.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.5.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.5.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.6.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.6.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.6.2|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.7.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.7.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.8.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.8.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.9.0|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.9.1|don't install laravel/framework v5.6.38
- don't install illuminate/events v7.9.2|don't install laravel/framework v5.6.38
- Installation request for laravel/framework (locked at v5.6.38, required as 5.6.*) -> satisfiable by laravel/framework[v5.6.38].

我尝试过的:

重启 xampp 许多不同版本的 monogodb dll。线程安全和非线程安全。我的 phpinfo 页面显示线程安全已启用,所以我想我应该选择线程安全版本,但我都尝试了以防万一,但两者都不起作用。我什至尝试过 x86 版本。 我尝试过“composer require jenssegers/mongodb:dev-develop”和“composer require jenssegers/mongodb --ignore-platform-reqs”,但出现同样的错误

可能是什么问题?

php 版本 7.4.9

laravel 版本 8.6.0

我尝试使用的 mongodb dll 是最新的 (php_mongodb-1.8.0-7.4-ts-vc15-x64) 正如我所说,我也尝试过旧的

【问题讨论】:

【参考方案1】:

您是否阅读过该错误消息?它不包含对 mongodb 的任何引用,但会告诉您当前已在 v5.6.38 中安装了laravel/framework。这与最新版本的jenssegers/mongodb 不兼容。

尝试使用composer require jenssegers/mongodb:"^3.5"安装它

此外,您还应该计划更新 Laravel。 v5.6.38 已经有两年多了,等久了会面临更多的库不兼容问题。

【讨论】:

以上是关于为 php 安装 MongoDB 驱动程序出错(Windows)的主要内容,如果未能解决你的问题,请参考以下文章

编译php时,出错bad interpreter

使用 MongoDB 命令时出错

php 怎么进入mongodb

在 pymongo Mongodb 中查找值时出错

markdown 使用pecl安装php mongodb驱动程序

JHipster 和 mongodb:创建名称为“mongobee”的 bean 时出错