The Zaksoup Blog

Things that Zak Soup think are worth mentioning. Mostly stuff that nobody else does.

Connecting to MongoHQ with PHP

It’s actually deceptively simple.

The standard PHP mongo pecl extension goes like this: $databaseVariable = new Mongo(“mongodb://[urlwheremongoishosted].com”);

With MongoHQ it’s basically that form. You must know a couple of things first. The Server your database is hosted on, the port it’s on, and the database user and password. For example, my app’s databse page looks like http://d.pr/HuPX

after you create a user just set up your mongo class like this:

$databaseVariable = new Mongo(“mongodb://[database_username]:[password]@[server].mongohq.com:[port]/[database_name]”)

easy peasy

  1. zaksoup posted this