安装PHP 7 MongoDB客户端/驱动程序? [英] Installing the PHP 7 MongoDB Client/Driver?

查看:93
本文介绍了安装PHP 7 MongoDB客户端/驱动程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常想开始使用PHP 7,但是有一个问题正在困扰着……我主要将MongoDB用于数据库,问题是我不知道如何安装MongoDB驱动程序/客户端.适用于PHP 7.

I am very eager to start working with PHP 7 however one issue is getting in the way... I primarily use MongoDB for the database, and the problem is that I don't know how to install the MongoDB driver/client for PHP 7.

我当前的安装是PHP 5.6,在Mac上,brew install php56-mongo可以解决问题.

My current installation is PHP 5.6 and on my Mac and brew install php56-mongo does the trick.

任何人都可以推荐我如何在Mac或Ubuntu安装上使用它吗?

Can anyone recommend how I can get this working on my Mac or an Ubuntu install?

在此先感谢并深表感谢!

Thanks in advance and much appreciated!

推荐答案

PHP版本 5.99.99或更早版本的Mongo扩展已被取代:

The Mongo extension for PHP Version 5.99.99 or older has been superseded:

https://pecl.php.net/package/mongo

使用更新版本的PHP版本 7.99.99 或更旧的版本:

Use the newer one for PHP Version 7.99.99 or older instead:

https://pecl.php.net/package/mongodb

您可以自动安装PECL/PEAR扩展 :

You can install a PECL/PEAR extension automatically:

pecl install mongodb

手动

课程也已更改:

new \MongoClient(); // legacy class!

请参见 http://php.net/manual/en/book.mongo.php

new \MongoDB\Driver\Manager(); // new classes! 

请参见 http://php.net/manual/en/set.mongodb.php

有关兼容性的其他信息可以在这里找到:

Additional information regarding compatibility can be found here:

https://docs.mongodb.org/ecosystem/drivers/php/#兼容性

这篇关于安装PHP 7 MongoDB客户端/驱动程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆