Home A Quick Look at ORM for PHP

A Quick Look at ORM for PHP

If you have ever pulled your hair out over maintaining SQL statements intermingled with your PHP project code you might not be alone. Perhaps you considered abstraction or wished your database had an API. You might have even heard of an Object Relational Mapper (ORM).

Let’s take a quick look at ORM for your next PHP project.

The Perfect (st)ORM

The ORM offerings for PHP projects have come a long way. A query on stackoverflow returns over 100 hits on php+orm. With that in mind, focusing on one PHP ORM might be helpful as you to consider your next PHP project.

As with any solution in the PHP community you can expect to see several contenders for the best mousetrap prize. While no ORM is perfect, each will cater to specific needs and have varied levels of integration or consideration for PHP frameworks. Features can range from simplified abstraction to code generation to support for various underlying databases such as MySQL, PostgreSQL, SQLite, Firebird to IBM DB2, Microsoft SQL Server, and Oracle.

Doctrine was mentioned recently in the RWH review of zfKit as part of its easy out-of-the-box Zend Framework experience. You may also find features in the Doctrine 2.0 release to be of interest if you need caching or support for writing your own interfaces and abstract classes for when your database of choice is not supported at the time of a stable release.

A recent presentation highlighted Doctrine 2.0 as being a fresh take on the expansion of the PHP ORM options showing up in sourceforge, github, and related project hosting services.

Doctrine 2 – Not The Same Old Php Orm

View more

presentations

from

Jonathan Wage

.

(Slide 14 is an instant favorite)

I want a $drug->new()

Of course, even if you focus on Doctrine you find references to alternative ORM options such as Propel. This is because an ORM can often be found intermingled in wider discussion of PHP MVC frameworks.

For example, Propel is often mentioned in relation to Symfony and CodeIgniter or as another alternative to using Doctrine with other PHP MVC frameworks. In addition, the Propel blog is a good resource for extracting the value when using Propel or any ORM in general.

Again, there is more than just one ORM option in the PHP community. You may have even ended up writing your own at one point or found your MVC framework came with a library that supplied ORM functionality.

When selecting an ORM, what are your considerations? What did you expect to gain from the ORM? Have you had success or strugles with use of an ORM in your projects?

Let us know in the comments below!

About ReadWrite’s Editorial Process

The ReadWrite Editorial policy involves closely monitoring the tech industry for major developments, new product launches, AI breakthroughs, video game releases and other newsworthy events. Editors assign relevant stories to staff writers or freelance contributors with expertise in each particular topic area. Before publication, articles go through a rigorous round of editing for accuracy, clarity, and to ensure adherence to ReadWrite's style guidelines.

Get the biggest tech headlines of the day delivered to your inbox

    By signing up, you agree to our Terms and Privacy Policy. Unsubscribe anytime.

    Tech News

    Explore the latest in tech with our Tech News. We cut through the noise for concise, relevant updates, keeping you informed about the rapidly evolving tech landscape with curated content that separates signal from noise.

    In-Depth Tech Stories

    Explore tech impact in In-Depth Stories. Narrative data journalism offers comprehensive analyses, revealing stories behind data. Understand industry trends for a deeper perspective on tech's intricate relationships with society.

    Expert Reviews

    Empower decisions with Expert Reviews, merging industry expertise and insightful analysis. Delve into tech intricacies, get the best deals, and stay ahead with our trustworthy guide to navigating the ever-changing tech market.