PHP code example of crodas / activemongo2

1. Go to this page and download the library: Download crodas/activemongo2 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

crodas / activemongo2 example snippets


// /tmp/mapper.php would be generated
$conf = new \ActiveMongo2\Configuration("/tmp/mapper.php");
$conf->addModelPath(__DIR__ . "/app/model");
$conf->development(); // remove this line at production

// create mongodb connection
$mongo = new \MongoClient;

// create the ActiveMongo2 connection
$conn  = new \ActiveMongo2\Connection($conf, $mongo, 'database');