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, need further clarification, something is not working or do you have a request for another Ionic post? Furthermore, if you don't like something about this blog, if something is bugging you, don't like how I'm doing stuff here, again leave me a comment below. I'm here to help you, I expect the same from you. Feel free to comment below, subscribe to my blog, mail me to dragan.gaic@gmail.com, or follow and mention me on twitter (@gajotres). Thanks and have a nice day!

PS. If you want my help, if possible (even if it takes you some time to do that), create a working example I can play with. Use Plunker for AngularJS based questions or jsFiddle for jQuery/jQuery Mobile based questions.


 
Let’s look at a list of my chosen 10, in alphabetical order:
 
 
 
6. Idiorm
Official Site GitHub Documentation
 
 

Pro

 
  • 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)
 

Con

 
  • 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

 

Example

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

$user->first_name = 'Jamie';
$user->save();

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

foreach ($tweets as $tweet) {
    echo $tweet->text;
}
 
 
 
7. NotORM
Official Site GitHub Documentation
 
 
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.
 

Pro

 
  • 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.
 

Con

 
  • 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

 

Example

 
<?php
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
    }
}
?>
 

Notes

 
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.
 
 
 
8. Propel
Laravel Logo
 
 
Official Site GitHub Cheatsheet Documentation
 
 
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.
 

Pro

 
  • 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
 

Con

 
  • 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)

 

Example

 
<?php
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'));
?>
 

Notes

 
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

  • antonio garcia

    Two things
    1. A little typo in CONS of Idiorm. You repeat the comment of Fluorish 🙂
    2. Other option is Paris (Active Record) http://j4mie.github.io/idiormandparis/ created by the same author of Idiorm.

    Awesome comparative.

  • Vineel Shah

    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!

  • (Disclaimer: I wrote this package.) Also check out LessQL: http://lessql.net/ – it’s basically a much improved version of NotORM, fully tested, actively maintained, and has much better documentation.

  • BioHazard

    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 (http://dbphp.net/what-is-orm-what-is-object-relational-mapper/) which I use because of simplicity.

  • Boban Acimovic

    Your Propel example is just a custom query. You should have given an ActiveQuery example.

  • DasLicht

    +1 for RedBeanPHP !

  • Bartek Zdanowski

    Kudos for this article!