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

1
2
3
4
5
6
7
8
9
10
11
$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';

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

It took me all of 10 minutes to do this.

3 comments
SamuelCarlier
SamuelCarlier

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

Post Navigation

Web Analytics