[英]How can i configure xampp to install php mongo driver for latest version of php version 7.1 and connect to mongodb from php script
I am using window 10 ,xampp php version 7.1.1 ,architecture x86,vc14 and i have configure my xampp for connect to mongo database and mogodb extension is shown on my php_info page but still i am unable to connect to mongodb with php script. 我正在使用窗口10,xampp php版本7.1.1,体系结构x86,vc14,并且我已经将我的xampp配置为连接到mongo数据库,并且mogodb扩展名显示在我的php_info页面上,但仍然无法使用php脚本连接到mongodb。
What i have done till now on my window 10 is listing as below. 到目前为止,我在窗口10上所做的工作如下所示。
download php_mongodb-1.2.8-7.1-ts-vc14-x64 driver and paste it to xampp/php/ext 下载php_mongodb-1.2.8-7.1-ts-vc14-x64驱动程序并将其粘贴到xampp / php / ext
add extension to php.ini file in xampp as extension=php_mongodb.dll 将扩展名添加到xampp中的php.ini文件中,扩展名为extension = php_mongodb.dll
and it show mongodb extension to php_info page as 并且它将mongodb扩展显示为php_info页面,如下所示
i try this script to connect to mongo db 我尝试使用此脚本连接到mongo db
echo 'connection to mongodb database successfully'; //select database $db=$m->martvalley; echo 'databse:martvalley is selected'; $coll=$db->seller; echo 'collection seller is sellected from database:martvalley'; $doc=array( 'id'=>'4', 'seller_name'=>'hello seller' ); $coll->insert($doc); echo 'document inserted in collection:seller of database:martvaley';
but show me this error on browser 但在浏览器上向我显示此错误
Notice: Undefined property: MongoDB\\Driver\\Manager::$martvalley in D:\\php\\htdocs\\MongoDB-Script\\select-db.php on line 8 注意:未定义的属性:第8行的D:\\ php \\ htdocs \\ MongoDB-Script \\ select-db.php中的MongoDB \\ Driver \\ Manager :: $ martvalley
Notice: Trying to get property of non-object in D:\\php\\htdocs\\MongoDB-Script\\select-db.php on line 12 注意:尝试在第12行的D:\\ php \\ htdocs \\ MongoDB-Script \\ select-db.php中获取非对象的属性
Fatal error: Uncaught Error: Call to a member function insert() on null in D:\\php\\htdocs\\MongoDB-Script\\select-db.php:21 Stack trace: #0 {main} thrown in D:\\php\\htdocs\\MongoDB-Script\\select-db.php on line 21 致命错误:未捕获错误:在D:\\ php \\ htdocs \\ MongoDB-Script \\ select-db.php:21中对成员函数insert()的null进行调用堆栈跟踪:#0 {main}抛出在D:\\ php \\第21行的htdocs \\ MongoDB-Script \\ select-db.php
it may be possibly dublicate of other question,but i could not got any proper solution to resolve this issue,any detail desciption are also appreciable because i am little bit confuse by others answers. 这可能与其他问题有关,但我没有任何适当的解决方案来解决此问题,任何细节描述也都可以理解,因为我对其他答案有些困惑。
Use the newer one for PHP Version 7: 将较新的版本用于PHP版本7:
https://pecl.php.net/package/mongodb https://pecl.php.net/package/mongodb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.