【发布时间】:2020-03-03 08:29:08
【问题描述】:
我已经在我的 mac Catalina 10.15 上安装了 mongodb。我也安装了php7.3版本。现在,我想在 PHP 中使用 mongoClient() 类。我试过 composer require mongodb/mongodb 但它说缺少 mongodb 扩展:
Using version ^1.5 for mongodb/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
- mongodb/mongodb 1.5.1 requires ext-mongodb ^1.6 -> the requested PHP extension mongodb is missing from your system.
- mongodb/mongodb 1.5.0 requires ext-mongodb ^1.6 -> the requested PHP extension mongodb is missing from your system.
- Installation request for mongodb/mongodb ^1.5 -> satisfiable by mongodb/mongodb[1.5.0, 1.5.1].
To enable extensions, verify that they are enabled in your .ini files:
- /etc/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.
所以我尝试使用the php doc 安装 php 的扩展,但我收到了这个错误:
pear/install/mongodb/php_phongo.c -fno-common -DPIC -o .libs/php_phongo.o
/private/tmp/pear/install/mongodb/php_phongo.c:22:10: fatal error: 'php.h' file not found
#include <php.h>
^~~~~~~
1 error generated.
make: *** [php_phongo.lo] Error 1
ERROR: `make' failed
有什么帮助吗?
【问题讨论】:
-
在 mac 上安装 php 工具似乎很困难。您使用哪个框架来安装它? PECL,布鲁?你安装了autoconf吗?最重要的是 PHP 驱动程序页面顶部有一个警告 - 警告 此扩展已被弃用。相反,应该使用 MongoDB 扩展。 Gads,他们在说什么。我需要一个算命先生来帮忙。
-
@barrypucker 我使用mac os自带的PHP版本,PECL为php安装mongodb驱动
标签: mongodb php-7 macos-catalina