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:
- Document-oriented storage (the power and flexibility of JSON-like data schemas)
- Dynamic queries
- Full index support, including secondary indexes, inner-objects, embedded arrays, geospatial
- Query profiling
- Fast, in-place updates
- Efficient storage of binary data large objects (e.g. photos and videos)
- Replication and fail-over support
- Auto-sharding for cloud-level scalability
- MapReduce for complex aggregation
- Commercial Support, Training, and Consulting
MongoDB bridges the gap between key-value stores (which are fast and highly scalable) and traditional RDBMS systems.
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:
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.
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 ?