by Kevin Schroeder | 11:59 am

With the release that occurred on March 4th we have added Mongo support to the DevCloud.  So connecting to a Mongo instance is extremely easy to do now.  We don’t provide access to a Mongo collection but you do have the tools to connect to various Mongo service providers.  For this example I used MongoHQ though any service running Mongo sound work.

First go to whichever service you are using and create a new collection.  Like this

Then click on the Zend Server link for your container.  Like this

Go to Server Setup / Extensions and enable Mongo.  Like this

Restart Zend Server and deploy code.  Like this

1
2
3
4
5
6
7
8
9
10
11
$db = new Mongo('mongodb://kschroeder:[email protected]:10050/kschroeder');
 
$collection = $db->kschroeder->views;
 
$collection->insert(
array(
'view' => new MongoDate()
)
);
 
echo $collection->count() . ' views on this page';

Now you’re doing Mongo on the DevCloud like a boss.

It took me all of 10 minutes to do this.

Comments

azharuddin31

This seems to be pretty easy..

Mar 12.2012 | 04:59 pm

SamuelCarlier

is mongohq on the same network as zendserver? other wise the latency will be unacceptable

Apr 04.2012 | 02:32 am

    kschroeder

     @SamuelCarlier For development purposes it would be fine unless you’re dealing with huge amounts of data.  My own testing has shown that while there is additional latency, it’s not actually too bad.

    Apr 04.2012 | 07:52 am

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.