Sunday, September 10, 2006

Propel - worth taking a look at.

As a part of familiarising myself with some OOP design patterns i played around with Data Mappers (as a part of my personal page). One thing that i noticed very quickly was that i was repeating a lot of common code but with enough variations that i couldn't refactor it, specically the CRUD operations for a specific object.

I was musing over writing some "automatically generated" code to handle this (ie automatically generate CRUD functions for a specific object based on some definition) when i coincidentally stumbled onto Propel.

Propel does what i was looking for in reverse: it takes a database schema and produces an object that represents a row in the database (the Row Gateway Pattern).

A Row Data Gateway gives you objects that look exactly like the record in your record structure but can be accessed with the regular mechanisms of your programming language. All details of data source access are hidden behind this interface.
Now this is obviously a different beast to a Data Mapper but for my general coding needs it's quite a nifty solution (i don't often come across situations where my object structure is so complex that i need the benefits of a mapper... because i'm a novice!).

The way that it's designed (a port from Apache Torque) means that the generated classes merely form the base of your object and you're free (and encouraged) to extend and overwrite the base class as you see fit.

Combined with this object persistance is a DB abstraction layer that uses Creole (the roadmap looks to be heading towards PDO too).

Some have commented on how they disliked the build system, but having successfully installed Propel both locally and on my server i can't really see what there is to complain about: so far i've not encountered any real problems that would make me consider dropping it completely.

All-in-all, definitely worth a look if you're after some sort of object persistance in PHP.

0 Comments:

Post a Comment

<< Home