Home » Questions » Good PHP ORM Library?

Good PHP ORM Library?

Closed
0
0

Is there a good object-relational-mapping library for PHP?

I know of PDO/ADO, but they seem to only provide abstraction of differences between database vendors not an actual mapping between the domain model and the relational model. I’m looking for a PHP library that functions similarly to the way Hibernate does for Java and NHibernate does for .NET.

NOTE: This question was originally posted at StackOverflow.com by sgibbons

  • You must to post comments
-1
0

Look into Doctrine.

Doctrine 1.2 implements Active Record. Doctrine 2+ is a DataMapper ORM.

Also, check out Xyster. It’s based on the Data Mapper pattern.

Also, take a look at DataMapper vs. Active Record.

NOTE: This answer was originally posted at StackOverflow.com by Ian P

  • You must to post comments
1
0

There are only two good ones: Doctrine and Propel. We favor Doctrine, and it works well with Symfony. However if you’re looking for database support besides the main ones you’ll have to write your own code.

NOTE: This answer was originally posted at StackOverflow.com by Ilya Kochetov

  • You must to post comments
0
0

Doctrine is probably your best bet. Prior to Doctrine, DB_DataObject was essentially the only other utility that was open sourced.

NOTE: This answer was originally posted at StackOverflow.com by anon

  • You must to post comments
27
0

I’ve been developing Pork.dbObject on my own. (A simple PHP ORM and Active Record implementation)
The main reason is that I find most ORMs too heavy.

The main thought of Pork.dbObejct is to be light-weight and simple to set up. No bunch of XML files, just one function call in the constructor to bind it, and an addRelation or addCustomRelation to define a relation to another dbObject.

Give it a look: Pork.dbObject

NOTE: This answer was originally posted at StackOverflow.com by SchizoDuckie

  • You must to post comments
12
0

I just started with Kohana, and it seems the closest to Ruby on Rails without invoking all the complexity of multiple configuration files like with Propel.

NOTE: This answer was originally posted at StackOverflow.com by Zak

  • You must to post comments
1
0

If you are looking for an ORM, like Hibernate, you should have look at PMO.

It can be easily integrated in an SOA architecture (there is only a webservice classe to develop).

NOTE: This answer was originally posted at StackOverflow.com by anonymous

  • You must to post comments
1
0

Try RedBean, its requires:

  • No configuration
  • No database (it creates everything on the fly)
  • No models
  • etc.

It even does all the locking and transactions for you and monitors performance in the background. (Heck! it even does garbage collection….) Best of all… you don’t have to write a single… line of code… Jesus this, ORM layer, saved me ass!

NOTE: This answer was originally posted at StackOverflow.com by winterswk

  • Laurie
    +1 +1 +1 +! +! !!!!...jesus I read the first part of the documentation and it got me making sinister dictator laughter, and I'm downloading it already!

    NOTE: This comment was originally posted at StackOverflow.com by Kim Jong Woo

  • Terri
    I'm not a PHP guy, but I have to admit that looks pretty slick.

    NOTE: This comment was originally posted at StackOverflow.com by Chris Lively

  • Jeff
    I really don't want to be a downer, but this goes against everything I know -- that database tables should be designed with care (for performance) and that ALTER TABLE calls are expensive (and potentially dangerous).

    NOTE: This comment was originally posted at StackOverflow.com by NickC

  • Lynn
    @NickC Once you are finished developing the database can be 'frozen' to stop any more changes.

    NOTE: This comment was originally posted at StackOverflow.com by Sam

  • You must to post comments
3
0

My friend Kien and I have improved upon an earlier version of an ORM that he had written prior to PHP 5.3. We have essentially ported over Ruby on Rails’ Active Record to PHP. It is still lacking some key features we want such as transactions, composite primary key support, a few more adapters (only MySQL and SQLite 3 work right now). But, we are very close to finishing this stuff up. You can take a look at PHP ActiveRecord with PHP 5.3.

NOTE: This answer was originally posted at StackOverflow.com by Jacques Fuentes

  • You must to post comments
1
0

Try PHP ADOdb.

I can’t say it’s the best, because I haven’t used the others. But it’s fast, it supports Memcached and caching.

And it’s waaaay faster than Zend Framework’s DB/Select.

NOTE: This answer was originally posted at StackOverflow.com by Salam Fall

  • Peter
    ADOdb has an ORM (but isn't just an ORM). It's a really great solution generally, it works much better than Zend does for DB (as well as being slower than ADOdb, Zend DB has only limited JOIN support), it supports auto escaping with parameterisation (unlike say Doctrine) many different DB backends and has nice extendable caching design with super easy memcache integration. I don't think it's at all accurate to say it lends it self to a "Thin Model/Fat Controller" implementation (you can do that or not, but ADOdb's design doesn't favour one way or the other).

    NOTE: This comment was originally posted at StackOverflow.com by Iain Collins

  • You must to post comments
0
0

PHP ORM Faces For PDO extension. See PHP Faces Framework.

$urun = new Product();
$urun->name='CPU'
$urun->prince='124';
$urun->save();

NOTE: This answer was originally posted at StackOverflow.com by Kurt

  • You must to post comments
1
0

There’s a fantastic ORM included in the QCubed framework; it’s based on code generation and scaffolding. Unlike the ActiveRecord that’s based on reflection and is generally slow, code generation makes skeleton classes for you based on the database and lets you customize them afterward. It works like a charm.

NOTE: This answer was originally posted at StackOverflow.com by Alex Weinstein

  • You must to post comments
20
0

Try Doctrine2. It’s probably the most powerful ORM tool for PHP. I’m mentioning it separately from Doctrine 1, because it’s a completely different piece of software. It’s been rewritten from scratch, is still in beta phase, but it’s usable now and developed.

It’s a very complex ORM, but well designed. Lot of magic from original Doctrine 1 disappeared. It provides a complete solution, and you can write your own ORM on top of Doctrine2 or use just one of its layers.

NOTE: This answer was originally posted at StackOverflow.com by tomp

  • You must to post comments
-1
0

Axon ORM is part of the Fat-Free Framework – it features an on-the-fly mapper. No code generators. No stupid XML/YAML configuration files. It reads the database schema directly from the backend, so in most CRUD operations you don’t even have to extend a base model. It works with all major PDO-supported database engines: MySQL, SQLite, SQL Server/Sybase, Oracle, PostgreSQL, etc.

/* SQL */
CREATE TABLE products (
    product_id INTEGER,
    description VARCHAR(128),
    PRIMARY KEY (product_id)
);

/* PHP */
// Create
$product=new Axon('products'); // Automatically reads the above schema
$product->product_id=123;
$product->description='Sofa bed';
$product->save(); // ORM knows it's a new record

// Retrieve
$product->load('product_id=123');
echo $product->description;

// Update
$product->description='A better sofa bed';
$product->save(); // ORM knows it's an existing record

// Delete
$product->erase();

Most of all, the plug-in and accompanying SQL data access layer are just as lightweight as the framework: 14 KB (Axon) + 6 KB (SQLdb). Fat-Free is just 55 KB.

NOTE: This answer was originally posted at StackOverflow.com by stillstanding

  • You must to post comments
0
0

I found ORM related classes in the PHP library Flourish.

NOTE: This answer was originally posted at StackOverflow.com by VDVLeon

  • You must to post comments
1
0

Tried the ORM of Flourish library.

NOTE: This answer was originally posted at StackOverflow.com by eaguilar

  • You must to post comments
1
0

Look at http://code.google.com/p/lworm/ . It is a really simple, but powerful, lightweight ORM system for PHP. You can also easily extend it, if you want.

NOTE: This answer was originally posted at StackOverflow.com by Faz

  • You must to post comments
1
0

A really good simple ORM is MyActiveRecord. MyActiveRecord documentation. I have been using it a lot and can say it’s very simple and well tested.

NOTE: This answer was originally posted at StackOverflow.com by Szymon Wygnański

  • You must to post comments
1
0

Looked at Syrius ORM. It’s a new ORM, the project was in a development stage, but in the next mouth it will be released in a 1.0 version.

NOTE: This answer was originally posted at StackOverflow.com by biancardi

  • You must to post comments
1
0

Try PdoMap. Wikipedia claims that is inspired by Hibernate. Since I never used Hibernate, I cannot judge :), but I would say from my experience that is good and fast ORM that is easy to implement, with a less steep learning curve that other ORMs.

NOTE: This answer was originally posted at StackOverflow.com by aromawebdesign.com

  • You must to post comments
1
0

Another great open source PHP ORM that we use is PHPSmartDb. It is stable and makes your code more secure and clean. The database functionality within it is hands down the easiest I have ever used with PHP 5.3.

NOTE: This answer was originally posted at StackOverflow.com by Joe

  • You must to post comments
Showing 1 - 20 of 30 results