欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

Class 'MongoClient' not found

程序员文章站 2022-06-16 22:42:35
...
环境:
PHP5.6.2
Apache2

安装php-mongo driver

[Jack:~ $] sudo pecl install mongo
pecl/mongo is already installed and is the same as the released version 1.6.14

[Jack:~ $] vi /etc/php.ini
extension=mongo.so

[Jack:~ $] apachectl restart

我已经安装php-mongo driver,php.ini也添加了扩展,但是还是报这个错,怎么破?
代码:

报错:

Fatal error: Class 'MongoClient' not found in /private/var/www/index.php on line 5

回复内容:

环境:
PHP5.6.2
Apache2

安装php-mongo driver

[Jack:~ $] sudo pecl install mongo
pecl/mongo is already installed and is the same as the released version 1.6.14

[Jack:~ $] vi /etc/php.ini
extension=mongo.so

[Jack:~ $] apachectl restart

我已经安装php-mongo driver,php.ini也添加了扩展,但是还是报这个错,怎么破?
代码:

报错:

Fatal error: Class 'MongoClient' not found in /private/var/www/index.php on line 5

命令行执行php -m检查一下模块是否加载

你写错了,应该是new mongo

安装扩展你可以参考这个,基本一样的扩展

相关标签: php mongodb