Next Generation MongoDB Driver for PHP!
For the past few months I've been working on a "next-gen" MongoDB driver for PHP -- codename "phongo".
The aim was to build a new PHP extension ontop of the mongoc and libbson libraries to reduce maintenance of the extension itself and focus more on providing the ecosystem with improved support and libraries.
The new driver is available on PECL (called "mongodb", surprisingly enough). It doesn't include any of the bells and whistles found in the previous "mongo" driver. It doesn't include any `group` or `count` command helpers, and you won't find any Collection or Database objects; however, it really doesn't need any of these things.
All it has is simplicity. You can execute a command of your choosing. You can execute a query. You can execute a write. That's really it (as with everything, there are certain exceptions). Oh, it is also very, very fast.
For our new "mongodb" extension, the driver only implements the most essential features for interacting with a MongoDB server:
Furthermore, it should be faster. The legacy driver, which dates back five years, had unfortunate design quirks that couldn't be fully resolved without a costly rewrite (e.g. the way MongoGridFS invokes MongoCollection methods internally). Creating a brand new, no-frills[1], and simple to use driver gives us a fresh starting point for the next five years.
To that end, we are writing a PHP library on top of this new extension, which will have all of the frills, bells, and whistles you might expect. It implements the "Standard MongoDB Driver CRUD API" (among others) and we'll continue roll in new features into this library as needed. And because this library will be implemented in PHP, we expect to iterate on new features much more quickly than we were able to do with the legacy driver.
This won't be the only library we will be writing. There are also plans to develop a library to deal with MongoDB administrative tasks (e.g. creating users, reconfiguring wiredTiger nodes, tailing oplogs) and develop tools to introspect MongoDB clusters.
We would love to hear your feedback! Check out the projects on GitHub (driver, library), and let us know what you think.
[1] Well.. Almost. There is one frilled feature I'm excited about -- we'll cover that later.
The aim was to build a new PHP extension ontop of the mongoc and libbson libraries to reduce maintenance of the extension itself and focus more on providing the ecosystem with improved support and libraries.
The new driver is available on PECL (called "mongodb", surprisingly enough). It doesn't include any of the bells and whistles found in the previous "mongo" driver. It doesn't include any `group` or `count` command helpers, and you won't find any Collection or Database objects; however, it really doesn't need any of these things.
All it has is simplicity. You can execute a command of your choosing. You can execute a query. You can execute a write. That's really it (as with everything, there are certain exceptions). Oh, it is also very, very fast.
What's the Point?
Most developers interact with databases these days through their preferred framework abstraction layer. That layer often has its own way of providing the bells and whistles irrespective of the driver's functionality -- it seldom matters what helper methods the driver offers, since these libraries can call MongoDB::command() directly. Besides, upgrading the driver just to get a new command helper, which is easily implemented in userland PHP, is just weird.For our new "mongodb" extension, the driver only implements the most essential features for interacting with a MongoDB server:
- Server Discovery and Monitoring
- Automatic Server Selection (with manual selection possible) using Read Preferences
- BSON [en|de]coding (to/from extended JSON, too)
- Implementing the MongoDB wire protocol
Again, What's the Point?
Well, now we can provide you with a stable driver that really shouldn't change all that much, which means less extension upgrades.Furthermore, it should be faster. The legacy driver, which dates back five years, had unfortunate design quirks that couldn't be fully resolved without a costly rewrite (e.g. the way MongoGridFS invokes MongoCollection methods internally). Creating a brand new, no-frills[1], and simple to use driver gives us a fresh starting point for the next five years.
MongoDB PHP Libraries
Of course, we aren't planning on leaving our users out to dry. Whether or not your framework of choice offers an amazing MongoDB abstraction layer, we do want to make it easy, simple, and natural for you to develop applications with MongoDB.To that end, we are writing a PHP library on top of this new extension, which will have all of the frills, bells, and whistles you might expect. It implements the "Standard MongoDB Driver CRUD API" (among others) and we'll continue roll in new features into this library as needed. And because this library will be implemented in PHP, we expect to iterate on new features much more quickly than we were able to do with the legacy driver.
This won't be the only library we will be writing. There are also plans to develop a library to deal with MongoDB administrative tasks (e.g. creating users, reconfiguring wiredTiger nodes, tailing oplogs) and develop tools to introspect MongoDB clusters.
What do you think?
The biggest question at this point is: "what else?" What is missing? What are the other pain points you've experienced as a MongoDB developer, that the driver or a library can help with?We would love to hear your feedback! Check out the projects on GitHub (driver, library), and let us know what you think.
[1] Well.. Almost. There is one frilled feature I'm excited about -- we'll cover that later.
Comments
Post a Comment