Previously “Mongo” was the extension used for MongoDB (Legacy) driver for PHP. Now that is depreciated. Now “MongoDB” Pecl extension is used instead of “Mongo” Pecl extension. And MongoDB Driver is PHP’s official driver for MongoDB. Here is detail of this driver on php.net: http://php.net/manual/en/set.mongodb.php . It supports PHP as well as HHVM.
To have this MongoDB driver working, you need to install pecl “MongoDB” extension.
To install PHP MongoDB on Linux, follow below mentioned steps:
- Run this command:
sudo pecl install mongodb
- 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
To test your installation try instantiating “MongoDB\Driver\Client” by using code similar to this one:
$client = new MongoDB\Driver\Client("mongodb://localhost:27017");
If it says that MongoDB\Driver\Client not found or not defined then there is chance that MongoDB driver is not properly installed. However parameters to this constructor can be changed depends on your MongoDB URL.
In case of any problem, feel free to let me know in comments section.