Tuesday, June 14, 2011

Mongo Db

I started working on a new pet project -  creating a blogging system using PHP and mongoDb. I have a keen interest in NoSQL and I've been wanting to get my hands dirty with mongoDb for sometime now and this seems like as good a project as any to put the db through its paces.

I thought I would document the process here until my new mongo powered blog is working.

So far so good - I installed the mongoDb with no problem and went through the start-up guide on the mongoDb site.

Next I installed the php half of the equation - MongoDB database driver for php.
Unfortunately I didn't have pecl installed on my new MacBook Pro -  Curses A Road Block!
Running the commands:
curl http://pear.php.net/go-pear.phar > go-pear.php
php -d detect_unicode=0 go-pear.phar
got me the pear/pecl packages I needed.

Now I just ran:
pecl install mongo
and boom I had the drivers installed. All that was left was to update the php.ini file and restart Apache.

As a final step I created 2 pages.
postCreator.php - a page with a form that allows the user to create a new blog entry and insert it (blog it) into their collection. The page creates mongo records that consist of a few fields (username, timestamp, title, text, label, etc.)
view.php - a page which displays the blog entries.

So thats where I've gotten to. All matters of formatting and style sheets have to be worked out. As well as a commenting system and lots of other issues. Still, I'm impressed by how quickly I was able to get up and running with mongoDb.

Cheers,
TheSortedProgrammer

No comments:

Post a Comment