Connecting to Mongo

Mongo support is available for the Zend Developer cloud, though we do not provide a database instance. There are several Mongo hosting companies such as Mongo Labs or MongoHQ  that will provide some storage space for you, often for free.

The first thing you will need to do is get the URI for you to connect to from your service provider.

Then you will need to turn on the Mongo extension in Zend Server.  The Mongo extension is not turned on by default so you will need to  log in to the Zend Server Administration Panel from your container UI and turn it on.

Then you will need to go to the Server Setup / Extensions page and activate Mongo

From there you can write your code as you would any normal PHP/Mongo based application

$db = new Mongo('mongodb://kschroeder:536wesfdh5645g@staff.mongohq.com:10050/kschroeder');

$collection  = $db->kschroeder->views;

$collection->insert(
    array(
        'view' => new MongoDate()
    )
);

echo $collection->count() . ' views on this page';