You start by adding a connection from your MongoDB database to your Dependency Injection container, as in the following code snippet:

    $di->set('mongo', function() {
         $mongo = new \MongoClient();
        return $mongo->selectDb("blog");}, true);

This will be a connection to the default localhost MongoDB instance running on the default port. If mongodb of you requied password you just code like this

    $di->set('MongoDB', function () use ($config) {
        $mongo = new \MongoClient("mongodb://" .
           $config->database->mongo->username . ":"
           $config->database->mongo->password . "@" . 
           $config->database->mongo->host,array("db" => $config->database->mongo->dbname)
        return $mongo->selectDb($config->database->mongo->dbname);
    }, TRUE);