安装 PHP 7 MongoDB 客户端/驱动程序? [英] Installing the PHP 7 MongoDB Client/Driver?
问题描述
我非常渴望开始使用 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?
提前致谢,非常感谢!
推荐答案
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 install mongodb
或手动.
类也发生了变化:
new MongoClient(); // legacy class!
见 http://php.net/manual/en/book.mongo.php
new MongoDBDriverManager(); // 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屋!