peclmongodb扩展有两个,都是官方出品的,一个叫mongo,一个叫mongodb。前者已被官方废弃,不再提供稳定更新。官方推荐后者,后者支持php7。可以在pecl上搜索mongodb找到,也可以通过peclinstallmongodb安装。mongo和mongodb的结构完全不同,使用方式也大不相同,但是有一个官方的php适配包,可以让mongodb看起来类似mongo的体验https://github.com/mongodb/mo。..以上来自这个问题Thecurrentlyusedlaravel-mongodbWARNING:TheoldmongoPHPdriverisnotsupportedanotherinversions>=3.0.因为现在使用的是2.1版本,升级PHP7后使用的mongodb扩展与之前的mongo扩展不兼容,所以现在有2个方案:1、升级到3.0版本。2.使用https://github.com/alcaeus/mo...作为中间件,不修改现有代码。第二个解决方案来自http://php.net/manual/zh/set....有一个适配器-所以旧的MongoClient/MongoDB代码将在新的PHP7/Mongo混乱https://github.com/上运行alcaeus/mo...先不说第一种方案,现在说说第二种方案。composerconfig"platform.ext-mongo""1.6.16"&&composerrequirealcaeus/mongo-php-adapter然后测试Message::create(['title'=>'title','content'=>'content22','时间'=>时间()]);提示:ErrorExceptioninCollection.phpline42:Parameter1toMongoCollection::insert()expectedtobeareference,给定的值有问题怎么办?当然搜索了,于是谷歌,不得不说谷歌牛逼,第一个结果就找到了https://github.com/alcaeus/mo...搜不到bing.com就百度一下,或者搜索issue打开第二个链接https://github.com/jenssegers...看最后一个链接https://github.com/zamrih/lar...然后修改源文件jenssegers/mongodb/src/Jenssegers/Mongodb/Collection.php可以解决,但这不是一个好的解决方案。/***处理特定的插入调用。*不能动态处理,因为需要传递一个引用*@paramarray|object$document*@paramarray$options*@returnmixed*/publicfunctioninsert(&$document,array$options=[]){return$this->__call('insert',array(&$document,$options));}/***处理特定的batchInsert调用。*不能动态处理,因为需要传递一个引用*@paramarray$a*@paramarray$options*@returnmixed*/publicfunctionbatchInsert(array&$a,array$options=[]){return$this->__call('batchInsert',array(&$a,$options));}/***处理特定的保存调用。https://github.com/zamrih/laravel-mongodb/commit/8c3b4aaaee773e0c2968b4ff215ccec5305394e2*不能动态处理,因为需要传递引用*@param数组|对象$document*@paramarray$options*@returnmixed*/publicfunctionsave(&$document,array$options=[]){return$this->__call('save',array(&$document,$选项));}事实上,https://github.com/alcaeus/mo...给出了一个提示insert、batchInsert和save方法通过引用获取第一个参数。虽然原始API没有明确指定引用参数,但它确实向给定的对象和文档添加了一个ID字段。然后又出现了新问题:Fatalerror:CalltoundefinedmethodMongoDB\Driver\ReadConcern::isDefault()in..src\Operation\Find.phponLine193searchhttps://github.com/alcaeus/mo。..https://github.com/mongodb/mo...https://github.com/mongodb/mo...https://github.com/mongodb/mo...此提交添加了MongoDBDriverReadConcern::isDefault()但是他要求MongoDBextend1.3.0+因为默认版本是PHP5,所以peclinstallmongodb会提示peclconfig-showpecl/mongodbrequiresPHP(version>=5.5.0,version<=7.99.99),安装v版本是5.3.29Novalidpackagesfoundinstallfailedll/data/php7/bin/total124692-rwxr-xr-x1rootroot842Feb42016pear-rwxr-xr-x1rootroot863Feb42016peardev-rwxr-xr-x1rootroot779Feb42016pecllrwxrwxrwx1rootroot9Feb42016phar->phar.phar-rwxr-xr-x1rootroot14834Feb42016phar.phar-rwxr-xr-x1rootroot42332852Feb42016php-rwxr-xr-x1rootroot421615872016年2月4日php-cgi-rwxr-xr-x1rootroot35832016年2月4日php-config-rwxr-xr-x1rootroot431416432016年2月4日phpdbg-rwxr-xr-x1rootroot4537Feb42016phpize/data/php7/bin/peclinstallmongodb但是现在我用的是1.1.6版本,所以我要升级到http://pecl.php.net/package/m...下载最新版本http://pecl.php.net/get/mongo...tar-zxfmongodb-1.5.2.tgzcdmongodb-1.5.2whichphp7/data/php7/bin/phpizewhichphp-config./configure--with-php-config=/data/php7/bin/php-configmake&&makeinstallll/data/php7/lib/php/extensions/no-debug-zts-20151012/php7-i|grepextension_dirextension_dir=>/data/php7/lib/php/extensions/no-debug-zts-20151012=>/data/php7/lib/php/extensions/no-debug-zts-20151012sqlite3.extension_dir=>无值=>无值php7--iniConfigurationFile(php.ini)Path:/data/php7/etc/LoadedConfigurationFile:/data/php7/etc/php.iniScanforadditional.inifilesin:(none)解析的其他.ini文件:(none)vi/data/php7/etc/php.iniextension=mongodb.sophp7-m|grepmongodbphp7-i|grepmongodb链接:https://github.com/alcaeus/mo...https://github.com/mongodb/mo...https://github.com/alcaeus/mo...http://php.net/manual/en/mong...http://php.net/manual/zh/mong...http://php.net/manual/zh/set...https://github.com/mongodb/mo...https://secure.php.net/manual...https://github.com/mongodb/mo...https://github.com/alcaeus/mo...pecl替换对应的php版本wheel升级PHP7踩过的一些坑《PHP 开发者实践》PHP手册补充PHP7升级实战php7cc协助代码检查php5php7不兼容PHP7内核分析与升级PHP7操作MongoDB写给打算升级PHP7的小伙伴的文章
