douxiong2738 2014-08-20 16:47
浏览 36

使用MAMP找不到MongoClient类

  • I have downloaded and installed MongoDB.
  • I can interact with my db via the mongo shell.
  • I have installed the PHP extension through sudo pecl install mongo
  • I confirmed that mongo.so is in the folder defined by extension_dir in php.ini.
  • I have confirmed that extension=mongo.so is defined in php.ini.
  • I confirmed that the php.ini file I edited is the php.ini file being loaded for configuration via phpinfo().

Yet when I try to instantiate a new MongoClient, my script fails silently. And I when I try to run a command like php --rc MongoClient, I receive an error that the class does not exist. I have restarted apache (MAMP) and the computer and reverified config files multiple times. As I can use mongodb and mongo, I assume this is a PHP configuration issue, but I've double checked config multiple times. Any ideas?

Edit: php_error.log output:

[20-Aug-2014 18:54:03 Europe/Berlin] PHP Fatal error: Class 'MongoClient' not found in /Applications/MAMP/htdocs/pantry/application/controllers/mongodb.php on line 14

[20-Aug-2014 18:54:56 Europe/Berlin] PHP Warning: PHP Startup: mongo: Unable to initialize module

Module compiled with module API=20100525

PHP compiled with module API=20121212

These options need to match in Unknown on line 0

The issue now is clear, but I do not how to resolve it.

  • 写回答

1条回答 默认 最新

  • dongshu9458 2014-08-20 20:50
    关注

    Alright - so the final solution was hinted at around other similar questions. I had everything in the right place, using the right PHP, mongo, etc, but phpize was still configured with the wrong api version. So I downloaded the latest version of the applicable PHP source code, stuffed it all in /Applications/MAMP/bin/php/php5.5.10/include/php, reran pecl, restarted apache, and am good to go.

    评论

报告相同问题?

悬赏问题

  • ¥20 易康econgnition精度验证
  • ¥15 线程问题判断多次进入
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致