Best available PHP ORM libraries – Part 2

Written by on April 7, 2015

Best available PHP ORM libraries – Part 2

This is a follow-up article, go here if you want to read original one.

I will try to be as objective as I can. Before I chose these frameworks, I spent a lot of time searching for the perfect one. Everything said here doesn’t mean other frameworks are not worthy or inadequate.

Note: If this tutorial was helpful, you need further clarification, something is not working or you have a request for another Ionic post? Furthermore, leave me a comment below if you don't like something about this blog, if something is bugging you, don't like how I'm doing stuff here. Feel free to comment below, subscribe to my blog, mail me to Thanks and have a nice day!

Let’s look at a list of my chosen 10, in alphabetical order:

[heading size=”32″]6. Idiorm[/heading]

Official Site


  • PHP 5.2.0+ – may work on earlier versions with PDO and the correct database drivers
  • Very light ORM layer
  • Built on top of PDO
  • Works out of the box, given only a connection string (Consists of one main class called ORM. Additional classes are prefixed with Idiorm. Minimal global namespace pollution)


  • If you are working with complex data models and larger datasets consider using a different library, Idiorm is simply not advanced enough
  • Limited DB support: SQLite, MySQL, Firebird and PostgreSQL
  • If you are working with complex data models and larger datasets consider using a different library, Idiorm is simply not sophisticated enough
  • It assumes too much, similar to the Eloquent ORM


$user = ORM::for_table('user')
    ->where_equal('username', 'j4mie')

$user->first_name = 'Jamie';

$tweets = ORM::for_table('tweet')
    ->join('user', array(
        '', '=', 'tweet.user_id'
    ->where_equal('user.username', 'j4mie')

foreach ($tweets as $tweet) {
    echo $tweet->text;

[heading size=”32″]7. NotORM[/heading]

Official Site

NotORM is a PHP library for simple working with data in the database. The most interesting feature is a very easy work with table relationships. The overall performance is also crucial, and NotORM should run faster than a native driver. NotORM for databases is like SimpleXML for XML documents.


  • PHP 5.1 +
  • Fast
  • Very light ORM layer
  • Built on top of PDO (supports MySQL, SQLite, PostgreSQL, MSSQL, Oracle). Other PDO enabled databases are not tested but they should work.
  • Arguably best light ORM. According to my performance tests, it’s a little bit faster then Doctrine2 and Propel, but it lacks real complexity.


  • NotORM = Not having a proper documentation
  • If you are working with complex data models and larger datasets consider using a different library, NotORM is simply not sophisticated enough
  • I would not trust the claim that it runs faster than native drivers. I couldn’t confirm it while I was testing it. I’m not saying it’s not true, more testing is required to confirm or reject this claim.
  • Almost non-existent support … NotORM is a foundation for the Nette Framework which left it forgotten


include "NotORM.php";
$connection = new PDO("mysql:dbname=software");
$software = new NotORM($connection);

foreach ($software->application()->order("title") as $application) { // get all applications ordered by title
    echo "$application[title]\n"; // print application title
    echo $application->author["name"] . "\n"; // print name of the application author
    foreach ($application->application_tag() as $application_tag) { // get all tags of $application
        echo $application_tag->tag["name"] . "\n"; // print the tag name


NotORM is an excellent light ORM. Only reason, I’m not using it, is below average documentation (documentation must be the primary cornerstone of every good library or framework) and almost non-existent support.

[heading size=”32″]8. Propel[/heading]

[frame align=”center”]Laravel Logo[/frame]

Official Site

A highly customizable and blazing fast ORM library for PHP 5.4+. Propel 2 represents an evolution of previous versions: it follows PSR-0, PSR-1, PRS-2, PSR-3 Php standards. It has a more rational architecture and some enhancements which improve its features and make your coding easier and more enjoyable. But it presents some backward compatibility breaks. Migrating your projects from Propel 1.x to Propel 2 is easy, but it needs some work and a bit of attention.


  • PHP 5.4 +
  • Fast (achieve runtime speed through code generation)
  • Very versatile (ActiveRecord implementation)
  • Excellent choice for small, medium and large projects
  • Excellent documentation – it didn’t use to be like this before (I still don’t like it because of it)
  • It uses PDO (supports MySQL, SQLite, PostgreSQL, MSSQL, Oracle). Other PDO enabled databases should work.
  • IDE friendly – auto generated code means code completion is available
  • Better learning curve then in case of Doctrine
  • 3rd party visual editors
  • Enterprise support


  • Not the best choice if you are limited with older PHP version.
  • Building the model classes can become hell if you don’t have predefined tables
  • Table joins are pain in the neck (older Propel versions)


use Propel\Runtime\Propel;
$con = Propel::getWriteConnection(\Map\BookTableMap::DATABASE_NAME);
$sql = "SELECT * FROM book WHERE id NOT IN "
        ."(SELECT book_review.book_id FROM book_review"
        ." INNER JOIN author ON (book_review.author_id=author.ID)"
        ." WHERE author.last_name = :name)";
$stmt = $con->prepare($sql);
$stmt->execute(array(':name' => 'Austen'));


Usually, Doctrine or Propel will probably be your primary choice. If you still can’t decide you should google ActiveRecord vs. DataMapper, maybe that will give you a better perspective (you won’t miss either way).

I used to hate it. Propel 1.5 way my first PHP ORM and I didn’t understand some mechanics. It had a bad documentation; I couldn’t use it properly with Oracle; table joins were pain in the neck. Thankfully things improved considerably with Propel2.

I would advise you to try both Propel2 and Doctrine2, take some time playing with them. It is the only way I can think of where you could get ta best overview between them.

Continue Reading


8 thoughts on “Best available PHP ORM libraries – Part 2”

  1. Wow, great article. The code examples cut out hours of docs-reading to help me compare them. Thanks so much for the work, reading this has really helped me figure out how to approach my new project!

  2. You know what is interesting almost all orms listed in this article do not require to have your own classes or if they do they force you to derive classes in your model from their base classes while putting their static or non static method junk in your logic. Meanwhile in PHP we are loosing something nice with what other enterprise development tools are proud.

    In a perfect world you have independent and nicely done classes in your model. This classes by itself “have no idea” how they are going to be stored or loaded in actual database and they operate on their so called business layer. On the same time you have some tool that links this classes to database and does not require some changes or extension of your classes to operate.

    For example if you have object $user of class user and that class has method $user->save() or user::save which we inherited from some orm’s base object class this is misunderstanding of orm concept. Instead you must have something like $database->user->save ($user). You see orm saves mapped user object and not object saves itself like it is done in Doctrine orm which is very complex and heavy or db.php orm ( which I use because of simplicity.

  3. I am using propel for years. I generate everything with one click button. Whole app. I do generate special classes that create slugs for REST api for each table or complex query with click of button. Propel rocks.

Leave a Reply