简体   繁体   English

$ Composer 找不到 mongodb 扩展,需要 Mongodb 扩展

[英]$ Composer can't find mongodb extension, required Mongodb extension

I'm using with latest php version 7.2 on macOS Mojave / macOS Big Sur / macOS Monterey / macOS Ventura and receiving error like我在 macOS Mojave / macOS Big Sur / macOS Monterey / macOS Ventura 上使用最新的 php 版本 7.2 并收到类似的错误

 $composer require mongodb/mongodb
Using version ^1.4 for mongodb/mongodb
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

For more information about question : see the screenshoot有关问题的更多信息:请参阅屏幕截图

在此处输入图像描述

Your requirements could not be resolved to an installable set of packages.您的要求无法解决为一组可安装的软件包。

Problem 1 - mongodb/mongodb v1.4.x-dev requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system.问题 1 - mongodb/mongodb v1.4.x-dev 需要 ext-mongodb ^1.5.0 -> 您的系统中缺少请求的 PHP 扩展 mongodb。 - mongodb/mongodb 1.5.x-dev requires ext-mongodb ^1.6 -> the requested PHP extension mongodb is missing from your system. - mongodb/mongodb 1.5.x-dev 需要 ext-mongodb ^1.6 -> 您的系统中缺少请求的 PHP 扩展 mongodb。 - mongodb/mongodb 1.4.2 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system. - mongodb/mongodb 1.4.2 需要 ext-mongodb ^1.5.0 -> 您的系统中缺少请求的 PHP 扩展 mongodb。 - mongodb/mongodb 1.4.1 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system. - mongodb/mongodb 1.4.1 需要 ext-mongodb ^1.5.0 -> 您的系统中缺少请求的 PHP 扩展 mongodb。 - mongodb/mongodb 1.4.0 requires ext-mongodb ^1.5.0 -> the requested PHP extension mongodb is missing from your system. - mongodb/mongodb 1.4.0 需要 ext-mongodb ^1.5.0 -> 您的系统中缺少请求的 PHP 扩展 mongodb。 **- Installation request for mongodb/mongodb ^1.4 -> satisfiable by mongodb/mongodb[1.4.0, 1.4.1, 1.4.2, 1.5.x-dev, v1.4.x-dev]. **- mongodb/mongodb ^1.4 的安装请求 -> 可由 mongodb/mongodb[1.4.0, 1.4.1, 1.4.2, 1.5.x-dev, v1.4.x-dev] 满足。

Installation failed, reverting ./composer.json to its original content.安装失败,正在将 ./composer.json 还原为其原始内容。

I have already installed mongoDB extension still receiving problem我已经安装了 mongoDB 扩展仍然收到问题在此处输入图像描述

Not sure what I've missed steps to installation.不知道我错过了什么安装步骤。 If anyone can help me with this composer problem, I'd greatly appreciate it.如果有人可以帮助我解决这个作曲家问题,我将不胜感激。 in advance Thanks.提前谢谢。

composer require mongodb/mongodb --ignore-platform-reqs作曲家需要 mongodb/mongodb --ignore-platform-reqs

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

Using version ^3.4 for jenssegers/mongodb
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing mongodb/mongodb (1.4.2): Downloading (100%)         
  - Installing jenssegers/mongodb (v3.4.5): Downloading (100%)         
jenssegers/mongodb suggests installing jenssegers/mongodb-session (Add MongoDB session support to Laravel-MongoDB)
jenssegers/mongodb suggests installing jenssegers/mongodb-sentry (Add Sentry support to Laravel-MongoDB)
Writing lock file
Generating optimized autoload files

在此处输入图像描述

composer require jenssegers/mongodb --ignore-platform-reqs It solved my problem. composer require jenssegers/mongodb --ignore-platform-reqs它解决了我的问题。

Install PHP extension by running this command on your terminal.通过在终端上运行此命令来安装 PHP 扩展。

sudo pecl install mongodb

At the end, you will see following information.最后,您将看到以下信息。

Build process completed successfully
Installing '/usr/local/Cellar/php/7.3.3/pecl/20180731/mongodb.so'
install ok: channel://pecl.php.net/mongodb-1.5.3
Extension mongodb enabled in php.ini

and then restart your PHP service.然后重新启动您的 PHP 服务。

This error will happen when using WAMP as there is an unique php.ini for WAMP and CMD.使用 WAMP 时会发生此错误,因为 WAMP 和 CMD 有一个唯一的 php.ini。

So you might have added the mongo-ext to your WAMP php.ini and so it looks as though it is running and included in the enabled extension's list.因此,您可能已将 mongo-ext 添加到您的 WAMP php.ini 中,因此它看起来好像正在运行并包含在启用的扩展程序列表中。 However, this is not available to the command line php.ini and also you need to confirm the CMD version of PHP you are running但是,这对命令行 php.ini 不可用,您还需要确认您正在运行的 PHP 的 CMD 版本

  • You can confirm your CMD PHP version in the windows ENV variable "path"您可以在 windows ENV 变量“路径”中确认您的 CMD PHP 版本
  • If the CMD php version is not the same as the version you have included your mongo-ext, you will have to either install the mongo-ext into that version of PHP or change your path variable to point to the version of PHP you are currently using如果 CMD php 版本与您包含的 mongo-ext 版本不同,则必须将 mongo-ext 安装到该版本的 PHP 中,或者更改路径变量以指向您当前的 PHP 版本使用
  • Then ensure that the extension=php_mongodb is setup in both your WAMP and CMD version of php.ini然后确保在您的 WAMP 和 CMD 版本的 php.ini 中都设置了extension=php_mongodb

In order to confirm you have been successful your mongo-ext will show in your phpinfo() and if you run php -m on the CMD it will show in the rendered list为了确认您已经成功,您的 mongo-ext 将显示在您的 phpinfo() 中,如果您在 CMD 上运行php -m ,它将显示在渲染列表中

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

The above is not the correct way to do it, as it will create problems into the future with other packages, updates and/or installs.以上不是正确的方法,因为它会在未来与其他软件包、更新和/或安装产生问题。

Please check if mongodb modules is installed请检查是否安装了mongodb模块

php -m php -m

Go to the installation directory and run the below command ( it will take some time)转到安装目录并运行以下命令(这将需要一些时间)

composer require mongodb/mongodb --ignore-platform-reqs作曲家需要 mongodb/mongodb --ignore-platform-reqs

This will ignore the MongoDB required packages & rest will be installed.这将忽略 MongoDB 所需的包并安装 rest。

If you want the MongoDB Module to be installed then execute the below command如果要安装 MongoDB 模块,请执行以下命令

sudo apt-get install php-mongodb sudo apt-get install php-mongodb

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

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