dongqiya9552 2016-01-20 01:29
浏览 70

Mac OS X MongoDB和MONGO PHP驱动程序

i try to install MongoDB and Mongo PHP Driver for 5.6.x for MAMP PRO , but i finishing installation (also i add extension on php.ini) but still doesn't work. Any one help me ?

  • 写回答

1条回答 默认 最新

  • dtsnx44260 2016-11-17 08:26
    关注

    it would be useful if you could give more information about versions (MAMPP version, MongoDB server version, Mongo driver version...).

    However the most common problem with Mongo and php is that there are two different drivers, both can be installed through PECL.

    • mongo-php : Legacy driver, not recommended anymore.

      sudo pecl install mongo

      Add to php.ini -> extension=mongo.so

    • mongodb-php : New driver, recommended.

      sudo pecl install mongodb

      Add to php.ini -> extension=mongodb.so

    While mongo-driver works with PHP versions < 7.0 mongodb driver works with PHP versions > 5.5. But some libraries are still using old mongo driver (i.e.doctrine) and could need an adapter if you want to work with the new driver.

    Old driver repo: https://github.com/mongodb/mongo-php-driver-legacy

    New driver repo: https://github.com/mongodb/mongo-php-library

    To be sure which driver is working in your system, you can perform this easy test. Create two PHP scripts with the following initialization:

    If this works then you have old driver installed $connection = new MongoClient({here your conn data})

    If this works then you have the new driver installed $connection = new MongoDB\Driver\Manager({here your conn data})

    Hope this will be useful for any user with the same problem on any platform. (Please note the extension for windows user will be .dll instead of .so)

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看