Mongo is official MongoDB driver for PHP. Here is detail of this driver on php.net: http://php.net/manual/en/mongo.manual.php . Mongo include MongoClient class which is required to connect MongoDB and required by several packages that bridge between MongoDB and PHP.
MongoClient works on almost all of Operating Systems including Windows, Mac OS X, Unix, and Linux; little- and big-endian machines. No matter 32 or 64-bit machines. PHP 5.3 through 5.6. To install it, there is a “mongo” package on PECL.
To install PHP Mongo on Linux, follow below mentioned steps:
- Run this command:
sudo pecl install mongo
- If response of above command is error with text “phpize not found” then you need to first run this command and then above one. Please note that this command is useful on Debian based distributions, for others please use appopiate command accordingly :
sudo apt-get install php5-dev
- Then add following line to php.ini
- Then you need to restart your apache or nginx . If you are using apache then use following command to reload it.
service apache2 reload
After this hopefully your PHPClient class will be working fine and you can test your code which use MongoClient class.
In case of any problem, feel free to let me know in comments section.