How to Install PHP MongoDB Driver for XAMPP on OSX?

六眼飞鱼酱① 提交于 2019-12-04 13:48:36

问题


I entered the following commands on my command terminal in order to use the 'MongoClient' with PHP on XAMPP on my Macbook Pro:

  • brew install wget
  • brew install autoconf
  • sudo /Applications/XAMPP/xamppfiles/bin/pecl install mongo
  • Added extension=mongo.so to php.ini /Applications/XAMPP/xamppfiles/etc
  • Restarted Apache

However, I have had no luck. I keep getting this error: Fatal error: Class 'MongoClient' not found in /Applications/XAMPP/xamppfiles/htdocs/xampp/index.php on line 5

I'm getting kind of frustrated because I don't really know what else to try. Any advice?


回答1:


You need to start mongod

brew update

brew install mongodb

mkdir -p /data/db

mongod --dbpath /data/db

Before running mongod for the first time, ensure that the user account running mongod has read and write permissions for the /data/db directory.

Install MongoDB PHP driver

brew install php56-mongo

OR

sudo pecl install mongo



来源:https://stackoverflow.com/questions/30204938/how-to-install-php-mongodb-driver-for-xampp-on-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!