Good PHP ORM library?

what is the Good PHP ORM Library?

Personally, my response is: none of them.

Don’t get me wrong, there are some pretty awesome options out there. But none of them work for me, and I use my own library which is suited to my way of working.

I think Doctrine pretty much has that market. :slight_smile:

If you’re going for simple and lightweight, have a look at idiorm.

If you’re going for a very big and complex project I’d recommend Doctrine2, but with that I also recommend you read the documentation very carefully before you start coding as there are a lot of gotchas and idiosyncrasies in there.

I disagree completely, ORM is there for a very good reason and proper usage of ORM improves the code’s modularity/reusability, making it more object oriented. Sure bad programmers may end up abusing it and instead produce a worse application, but that’s because they are bad programmers, not that ORM is a bad technology to use. There’s always a performance cost, but the magnitude is minor in most cases. If performance is that big if a concern we should use compiled languages like java and c# rather than dynamic languages like PHP, Python and Ruby to begin with.

The problems with the ORMs that I have used is that they don’t provide the full power of the underlying SQL so I have had to drop down to use the raw SQL at certain points in the code. For instance inner joins on queries where one has a “group by” clause. Maybe this is what the original author was referring to in respect to an impedance mismatch. Does even doctrine2 have this power natively?

The other thing is with the advent of NOSql databases it would seem to be an acknowledgement that relational databases alone are insufficient to represent all the object models out there.

So given the date of that article (ie 2006), maybe the author was right.

Sent from my XT316 using Tapatalk 2

On the other hand, given the fact that PHP ORMs are alive and well, it’s possible that the 7 year old article is outdated and wrong.

Widespread adoption of a technology doesn’t imply superiority. Maybe its marketing was better.

Nevertheless, ORM stands for “object relational model”. Not all databases are relational, for instance MongoDB. Google also has this with their Google App Engine as I understand it. (I forget the name of theirs.) Therefore, unless you believe those database technologies are completely wrong and their efforts a total waste of time then there still exists an impedance mismatch.

Sent from my XT316 using Tapatalk 2

Mongo has gained considerable strength in the last few years, and there’s no ORM to speak of with Mongo because it’s an Object Database. SQL still has it’s niche. I’m of the opinion that ORM systems are fine up to a point, but they cannot replace SQL itself.

I’m curious as to why you think MongoDB is not “relational”? MongoDB allows you to embed and reference documents.

It is perhaps interesting to note that the Doctrine 2 ORM supports MongoDB.

To clarify on my last post ORMs are designed only for records of relational data. Not all data is relational. Some is hierarchical and some may even be graph like. SQL can sometimes deal with this after a fashion (ie: self referencing table joins) but even then the results there are limited. Just not as limited as most ORMs. This is where I see the most significant impedance mismatching where ORM only handles a subset of SQL capability.

ORMs were only ever intended to map relational data to object models. New emergent database technologies like Mongo, Google App Engine and others may include non-relational data. Relational implies consistent data types across records. Non relational has no such constraint. Key-Value stores are one such example.

This also explains my comment about article posted in url link in previous post in this thread dated 2006 as being more relevant today. Their was an impedance mismatch back then (perhaps due to the relative immaturity of ORM technology back then and its failure to embrace the full power of SQL) and then is an impedance mismatch today (because database technology has moved on).

Maybe it will be solved one day with an “object non-relational mapper”. Who knows.

Sent from my XT316 using Tapatalk 2

Well ORM is highly useful since most data is still stored in relational database. So long as LAMP is still dominant in hosting environment this will stay the way it is. Sure there are MongoDB, NoSQL and even Object databases, but if you are developing a software like Wordpress, Drupal and VBulletin and expect your client users to have access to these non-relational database then sorry, your application is not likely to be widely used and you wont make money. Its a different story if you run a large application/site like Google, Facebook and Twitter with your own hosting/server environment, but thats a different story.

I have just completed a search project for a larger site that uses wordpress but the search is based in Elasticsearch (nosql) and I wrote a plugin to hook the taxonomies and the queries translated to json / Elasticsearch. It worked well so these systems are not necessarily exclusively reliant on a relational Db anymore.

You can also look at Eloquent, the ORM that comes in Laravel. If you use Composer then its pretty easy to load it up in your project. Otherwise also its not much of a big deal to get started with it. It has an easy to understand & use expressive API ([URL=“”]docs).