Using Mongo with PHPCloud

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

$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.

3 Thoughts to “Using Mongo with PHPCloud”

    1.  @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.

Leave a Reply

Your email address will not be published.