NoSQL Zone is brought to you in partnership with:

Eric is the Editorial Manager at DZone, Inc. Feel free to contact him at egenesky@dzone.com Eric has posted 804 posts at DZone. You can read more from them at their website. View Full User Profile

Book Review: MongoDB and PHP

04.19.2012
| 2735 views |
  • submit to reddit

Despite having been toying with MongoDB and PHP for quite a while, I've only just picked up and read the "MongoDB and PHP" by Steve Francia, published by O'Reilly (disclaimer: I've collaborated with Steve on a few articles and he sent me a copy of the book to read)

My first impressions are that this isn't a heavy book. I don't have the physical version but I'll have to look out for it at the next O'Reilly stand that I see. That said, it covered everything I think you need to get your PHP application using MongoDB and manages to throw in good chunk of advice about what to look out for when you do implement something in the real world.

The book warms up its PHP audience by slating both Ruby on Rails and ORMs in general, which does let you know where the author stands on those topics! MongoDB is introduced with an intelligent comparison to memcache, which is a great way of framing the problem in a way we're more likely to be familiar with, and the book also strikes comparisons with MySQL which I liked a lot.

The tone of the book is quite informal and approachable, the sample data raised a smile when I saw that we were storing "superpowers" for different users in the collection :) Much as I agree with Steve on many things, seeing him assert that developers should understand database indexes made me feel as if I was among friends, even though I wasn't familiar with all of the MongoDB elements that were shown. This book also does a great job of deferring to other resources where that is appropriate; in particular where some features of MongoDB will change rapidly and the online documentation is well-maintained.

Plenty of the more advanced concepts were also covered, and with nice examples. MongoDB has both indexes and an explain function so we can work on the way it performs - very valuable knowledge as we move to a new platform and get to know it. The basics of querying and designing schemas were covered, along with the aggregate functions offered by MongoDB and an overview of map reduce. Being able to do these operations on nested arrays is slightly counter-intuitive if you're used to relational data, but the book includes examples on doing so.

There is no hiding from the very lovely, very technical, features available in MongoDB and although this book doesn't drill into all the possible use cases of each one, it does cover some advanced topics such as sharding and GridFS which was completely new to me. Steve shows his hands-on experience with his words of warning on avoiding request injection in MongoDB, and also gives a brief showcase of some of the abstraction layers and other community-origin tools that have already sprung up around the MongoDB ecosystem.

Overall I thought the book was light and digestible, it was upbeat to read and I came away feeling empowered to put MongoDB into my PHP projects in new ways. Making a complex topic sound encouraging isn't always easy so that's quite an achievement!

Published at DZone with permission of its author, Eric Genesky. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)