简体   繁体   English

PHPMoAdmin Web 界面无法连接到 MongoDB

[英]PHPMoAdmin web interface can't connect to MongoDB

I've installed the PHPMoAdmin Web UI on Windows 10 using XAMPP.我已经使用 XAMPP 在 Windows 10 上安装了PHPMoAdmin Web UI

But when I navigate to the place I've installed it in my browser:但是当我导航到我在浏览器中安装它的地方时:

在此处输入图片说明

I get a message saying that the PHPMongoDB extension is missing.我收到一条消息,说缺少 PHPMongoDB 扩展。

Yet, when I look at my phpinfo page, the mongodb extension is right there:然而,当我查看我的 phpinfo 页面时,mongodb 扩展就在那里:

在此处输入图片说明

This is the code that tries to connect to MongoDB:这是尝试连接到 MongoDB 的代码:

protected function _mongo() {
    $connection = (!MONGO_CONNECTION ? 'mongodb://localhost:27017' : MONGO_CONNECTION);
    $Mongo = (class_exists('MongoClient') === true ? 'MongoClient' : 'Mongo');
    return (!REPLICA_SET ? new $Mongo($connection) : new $Mongo($connection, array('replicaSet' => true)));
}

And I am able to connect to mongodb on the command line:我可以在命令行上连接到 mongodb:

PS C:\Users\bluet> mongosh
Current Mongosh Log ID: 6171fd3f9a9ff1c66d90e4f7
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000
Using MongoDB:          5.0.1
Using Mongosh:          1.0.3

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting:
   2021-10-21T17:37:26.117-04:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

Warning: Found ~/.mongorc.js, but not ~/.mongoshrc.js. ~/.mongorc.js will not be loaded.
  You may want to copy or rename ~/.mongorc.js to ~/.mongoshrc.js.

What can I do to get PHPMoAdmin to connect?我该怎么做才能让 PHPMoAdmin 连接?

The phpMoAdmin project is not maintained anymore (the last commit was in 2017) and, as stated here , the PHP7 mongodb extension is not supported:phpMoAdmin项目不维护了(最后的提交是在2017年)和,如前所述这里,不支持MongoDB的PHP7扩展:

This is on the to-do list.这是在待办事项清单上。 Supporting the new MongoDB extension is a big job as the entire syntax has changed, and the only supported-method to continue to use the (substantially more user-friendly) legacy-syntax is to include a userland PHP library, which is not an ideal option for phpMoAdmin since one of the key ease-of-use factors is that it is contained in a single-file.支持新的 MongoDB 扩展是一项艰巨的工作,因为整个语法都发生了变化,唯一支持继续使用(对用户更加友好)遗留语法的方法是包含一个用户级 PHP 库,这不是一个理想的选择phpMoAdmin 的选项,因为关键的易用性因素之一是它包含在单个文件中。

A comment mentions a fork for PHP7:一条评论提到了 PHP7 的一个分支:

I forked the project here to make it work with PHP7 and mongodb/mongodb package (so, one requires to install package with composer).我在这里分叉了这个项目,使其与 PHP7 和 mongodb/mongodb 包一起工作(因此,需要使用 composer 安装包)。 The overall functionalities seem to work now.整体功能现在似乎可以工作了。

Another comment gives a list of alternative projects: 另一个评论给出了替代项目的列表:

Here are some alternatives to phpMoAdmin:以下是 phpMoAdmin 的一些替代方案:

https://github.com/lovetheidea/MoaDB https://github.com/tetreum/mongolo https://github.com/SamuelTS/MongoDB-PHP-GUI https://github.com/lovetheidea/MoaDB https://github.com/tetreum/mongolo https://github.com/SamuelTS/MongoDB-PHP-GUI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM