Apr 19 2010

MongoDB and PHP

Looked for a reliable document oriented database, and after some tests and code, decided to give a try on MongoDB for a small proof of concept that i am working on. On the rest of this post i will try to guide you through the main principles of MongoDB integration with PHP.

What is MongoDB ?

MongoDB (from “humongous”) is a scalable, high-performance, open source, dynamic-schema, document-oriented database. Written in C++, MongoDB features:

MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems.

From mongodb.org

How to install MongoDB ?

You can follow the great step-by-step article over at If Not True Than Else blog.

How to use MongoDB with PHP ?

Simple as adding a new PECL module.

sudo pecl install mongo

Enable extension on your php.ini file.
Add the line:

extension=mongo.so

Next to your extension list. Restart you web browser instance and you are ready to go.

Starting using your MongoDB with PHP

There are plenty of tutorials and how-to on the internet, although you can start by looking at php.net Mongo tutorials, they are quite detailed and intuitive.

http://www.php.net/manual/en/mongo.tutorial.php

A more detailed with real world examples article can be found at PHPClasses website.

Have you ever used document oriented databases ? What’s your take on this ?

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>