No, this is not about Doctrine and Propel, although I’m sure those are both really fine PHP ORM tools if you are willing to endure the learning curve. This is about 2 lesser known but notable ORM tools that deserve a nod of recognition. I’ve tried a number of PHP ORM tools over the last year and many of them had merit. In fairness, as you look at one attempt you begin to realize how much each of them owes to those that came before them. There are so many variations on a theme that you can easily get confused and give up in frustration. But my recent efforts have revealed two that I find very useful and note worthy depending on your project. Here is a quick run down on each.
Spot
Spot is the second attempt at a Data Mapper ORM implementation for PHP by Vance Lucas. Vance’s first attempt was titled PHPDataMapper a was and nifty attempt in it’s own right. Vance took what he learned and created Spot, the 2.0 implementation of his original ORM. Spot has straight forward configuration through object inheritance and is very easy to use once you get the hang of it. Spot supports HasOne, HasMany and HasManyThrough relationships. It solves the Lazy Loading problem and is hands down the best implementation of association management through an ORM model that I’ve encountered. The available documentation is spartan right now (I’m being kind), but Vance was kind enough to give me the few pointers I needed to get working quickly. If anyone is interested let me know and I can provide some demo code in a separate post.
Given how much I have enjoyed using Spot, I have only one minor quibble. As I looked at the implementation, I could not find a way to build Models dynamically at run time rather than pre-define them. Granted this is not a problem for many projects, but it was an issue for the last thing I was doing. Having said that if I do any PHP projects in the future with static data models then I’ll be using Spot to do them. If you have a similar need and value power and simplicity then I encourage you to give Spot a go!
RedBeanORM
RedBeanORM is the marvelous dynamic ORM by Gabor de Mooij. For anyone who has read my blog you probably know that I have an on-going love / hate relationship with RedBean. This ORM is crazy easy to use as it builds the data tables and relationships on the fly as you run your program. The ORM picks the most appropriate type for your data items and adds any fields that are missing to the table. It even builds associations through intersection tables. It is such a cool concept that I am constantly drawn to it. That is except for the fact that it builds associations through INTERSECTION TABLES! I was never a fan of this and I posted in the forum that using only intersection tables was overkill for many common relational models.
After much waiting I’m happy to report that as of version 2.0 Gabor has added N:1 relationship support that implements a foreign key! It’s like mana from digital heaven! The implementation is not as user friendly as Spot (I have to do some of the work myself, gasp!), but it does go a long way towards making the resulting data model more practical for larger relational problems. This coupled with the dynamic nature of RedBeanORM make it a very compelling tool. For my dynamic model science project I’m going to use RedBean. I’m not sure where it will end up, but I’m excited to jump in and give it another try!
So there you have it. A tale of two PHP ORM’s that deserve a little recognition for their authors’ hard work and vision to make something better than what was there before. It is the true spirit of open source and I salute both of them for doing such a great job. I’m excited about ORM tools again, and that’s saying something!


So I happened upon Vance’s http://alloyframework.org last week on my search for a good lightweight MVC framework for a large project. I spent the next 2 days working through the code (sparse docs but more than I could find on SPOT) and I like it very much and will probably use it. SPOT is plugged in and I was searching for some info on how to use it and found this article. I have not used an ORM before so I’d like to take you up on the demo code offer. Email would be great or a link to another post. Thanks much for time. Great article too!
DK, thanks for the comment. It’s late tonight, but tomorrow afternoon when I get home from work I’ll post some sample code for Spot to help you get started.
Ok, I’ve created a post here that might help. Post a comment here or on that post if you have other questions.
As of writing RedBeanPHP is at version 3.2 and as such many improvements have been made. Easily the best ORM without the bloat, at least in my opinion.
Doctrine and Propoel are very good products, heavyweights in the ORM landscape – but the learning curve is something you need to weigh against your project needs, is it worth it?
For me, project after project, even the complex ones – that answer is no, because there hasn’t been a situation where RedBeanPHP hasn’t been able to step up to the plate.
Spot ORM looks good, though for the same reasons above I’ll likely never use it on a regular basis not until it or others get that “on-the-fly” sugar happening.