Get Propelled!

 

About two years ago I read of an emerging ORM-solution called Propel.  Having just finished my first full readthrough of PHP 5 Object, Patterns, and Practice by Matt Zandstra, I was eager to research object relational mappers that differed from the one used in that book.  My experience was one of major disappointment.  After spending hours of frustration installing the library, and more hours configuring and running my first propel build, I ran a measly script to add an author to a bookstore database.  And it was slow…much slower than one file of PHP. I dropped Propel, deeming it too unstable and unpredictable to run in any redistributable software.

Times and ideas change, and software either matures or goes away.* I am happy to report that Propel has matured, and in my opinion is very ready to be packaged in your project of choice.

According to the Propel site, “Propel is based on Apache Torque, a well-established O/R solution for Java”, and contains two components – a generator for converting a database structure to a set of class files, and a runtime framework for accessing your database. The generator builds your files using Phing, making that package a dependency.

The installation is not bullet-proof, but much easier.  Installing through PEAR is as little as 4 steps…if your prerequisites are set.  But first the install.  Using PEAR from the command line (in Windows go to Start -> Run, and type cmd, then click Ok), type the following:

pear channel-discover pear.phing.info
pear install phing/phing
pear channel-discover pear.phpdb.org
pear install phpdb/propel_generator

I have left the runtime out of this installation description because it can and probably should be included in your project library. If you are redistributing Propel with your project, you can forego the generator and just include the runtime in the project root. If you are just running Propel on your own server without plans to redistribute, you can install the runtime through PEAR with the following command:

pear install phpdb/propel_runtime

The prerequisites are as follows:

  1. The XSL extension must be installed (or the generator will not install!)
  2. In php.ini, magic_quotes_gpc must be set to off
  3. In php.ini, zend.ze1_compatibility_mode must be set to off

The Propel site contains tutorials and examples for configuring and installing your first build. Sample project builds are included with the generator package as well. Propel features full model creation for your database, with foreign-key mapping support, method stacking, and even extendible validator classes! For larger sites & applications, Propel supports load balancing with read/write slaves connections.

So install Propel today, or research their thorough wiki, and get Propelled!

*unless your M$ and have hundreds of billions to burn up in oem deals and false advertising…
  1. No Comments