Autoload configuration doesn't load MongoDB classes

帅比萌擦擦* 提交于 2020-01-02 06:10:41

问题


I have MAMP 1.9 on MAC OSX 10.8.2 using PHP 5.3 I installed MongoDB and the PHP extension mongo.so and added it to my php.ini.

I can run the MongoDB on the console and my phpinfo says MongoDB support is enabled but I cannot run the following PHP script.

<?php $connection = new MongoClient(); ?>

PHP comes up with a fatal error:

Class 'MongoClient' not found

Something seems to be wrong with the autoload configuration of my MAMP (or the extension installation).


回答1:


As Sammaye mentioned in the comments above, it looks like you're simply running an older version of the driver. You can obtain the current version by either dumping Mongo::VERSION or the returned value from phpversion('mongo'). Instructions for installing/upgrading the drive via PECL are also documented; however, we no longer have pre-compiled versions available on GitHub (GitHub will soon be removing repository downloads, although we've recently begun publishing the Windows builds to S3).




回答2:


I had the same issue because I was changing wrong php.ini file. So I ran the below command

echo phpversion('mongo');

and took Loaded Configuration File which was /Applications/MAMP/bin/php/php5.4.4/conf/php.ini and changed it.

Restarted Apache and it worked.yay!!!



来源:https://stackoverflow.com/questions/14002074/autoload-configuration-doesnt-load-mongodb-classes

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!