Propel 1.6 + phpsh = Awesome CLI to your Database

Propel 1.6, the next iteration of the PHP ORM, is still under heavy development. But since it’s backwards compatible with previous versions, you can easily test it on an existing application. One good reason to try it on is to take advantage of the new ability of ActiveRecord and Query classes to be dumped to a YAML string.

And if you combine this ability with the power of phpsh - an interactive PHP shell utility which is to PHP what IRB is to Ruby - you’ve got a new way to interact with your domain model. Just feed phpsh with a bootstrap script that initializes Propel and autoload your model classes, and you're good to go. Check the following screencast for an example:

ActiveRecord and Query classes can also be dumped to XML, JSON, and CSV. You can visualize joined hydration. And you can use your custom filters, too!

No need to write a custom script to check the persisted objects of your domain model anymore. Combined with phpsh, Propel now almost feels like object-oriented database.

Posted by Francois Zaninotto 

5 comments

Sep 26, 2010
nsolsen said...
#Propel+#phpsh is a very nice combo indeed! This will be extremely useful. Thanks for sharing. :)
Oct 04, 2010
Andrew said...
Totally awesome! Can't wait for sfPropel16Plugin!
Jan 14, 2011
sachindurge said...
Hey man always surprises , we are awaiting to be more from you.
Mar 31, 2011
stickerous said...
Could you please paste this bootstrap script or point at location ?
Mar 31, 2011
@stickerous: It's somewhat similar to what the doc explains in the "Build Time" chapter. It should look like the following:

require_once __DIR__ . '/../../../runtime/lib/Propel.php';
set_include_path(__DIR__ . '/build/classes' . PATH_SEPARATOR . get_include_path());
Propel::init(__DIR__ .  '/build/conf/bookstore-conf.php');

Leave a comment...