Wide Niche Forest, trees, and balance within. I guess.


Torpor 1.0

As of this morning, after extensive testing and its first production beta deployment (which did result in a few minor bug fixes), I am pleased to announce that Torpor has reached release 1.0 (slightly delayed to allow for other DataStore adapters and management of pigfluenza in the home, but close enough for open source).

Things to check out:

On the whole, everything works.  Case sensitive collations under SQLite and SQL Server have issues, but mostly due to he limitations of those particular databases, and SQL Server cannot enforce DISTINCT selection when returned records include TEXT/CLOB columns (so DISTINCT is temporarily disabled in SQL Server - I've chosen to go live with the bug).  All told, these are fairly minor issues when everything else works so well.  All major features work in:

  • MySQL
  • Oracle
  • SQLite
  • SQL Server

An identical database has been ported to each of these database engines in turn, and the same code and same configuration XML (with minor adjustments to specify the new DataStore adapter) pass, exercise the full suite, on each.  Additionally, the provided Memcache adapter allows for distributed read/write-through caching for horizontal scalability at the app layer.

All DataStore and Cache adapters use generic interfaces, and the provided code serves well as examples of working implementations.  It should be possible with minimal effort to add additional DataStore components (even non-RDBMS adapters for XML, SOAP, etc.) or Cache's.

The 1.1 road map is being assembled, to include better performance through leveraging bind variables in those adapters which support it, Postgres (which will almost certainly come as an earlier component release), inferred joins and a join hint syntax, and custom reports / aggregate functions, etc.  Have a suggestion?  Create an issue in the project home page (same goes for bugs).

While it sounds like there's a lot to do, this is still an incredibly strong 1.0 offering especially in the PHP world (did I mention it passes E_ALL|E_STRICT error reporting?), and is being made use of professionally at the day job with excellent results.

The one lament, and this will be remedied over time, is the lack of end user documentation.  I've settled on the use of TiddlyWiki as a convenient mechanism for creating, storing, and distributing the documentation with the project, and will begin adding this as time permits (though it's now in competition with other projects, so not likely to move at the same speed with which Torpor has also matured).

For now: download, use, enjoy!

Filed under: Uncategorized No Comments

Zend Devzone PHP Abstract Podcast: Torpor

Recently I had the pleasure of being interviewed by Eli White of Zend, "The PHP Company," for the Devzone podcast PHP Abstract (by and for PHP developers).  The topic of discussion was Torpor, what it is, what it offers, and why it's being developed.

Despite my rambling on there's some useful information to be found - hardly all inclusive, but it should stand on its own as an introduction to the level of forethought that's gone into an undertaking of this complexity.

The ~20 minute recording posted today - go check out Episode 46!


Torpor 0.9β Released!

The 0.9 beta release of Torpor (all major features work, but only in MySQL and there's some definite clean-up and organization to be done) is available now:

TorporPHP_0.9b.tar.gz (via Google project hosting)

I also need to correct a statement I made earlier during the introduction of Torpor - this is not the first mature persistence layer abstraction.  I've come across others (turns out the buzz word for googling is "PHP ORM", not "PHP persistence abstraction") since I delved into this foray in the first place, though I can say I'm not especially impressed.  I can also say that Torpor easily stands on its own among these, with its philosophies fitting an appropriate niche and providing some of its own innovations (especially the intermediate cache interface and the complexity of the intrinsic deep-loading and relationship introspection).

Those feeling adventurous, enjoy!

Those without the cycles to spare, 1.0 should be available in 3-4 weeks, enabling additional database interfaces and cleaning things up.  Between 0.9b and 1.0 there may be some minor changes in naming conventions, but overall structure will remain the same.  Much documentation will be forthcoming as well.

Good luck, and good night!

Tagged as: , No Comments


Pronunciation: \ˈtôr-pər\

  1. Temporary or short-term hibernation, characterized physiological activity.
  2. The first mature persistence layer abstraction for PHP, provided by Yours Truly under the MIT license.

Link: torpor-php (via Google Project Hosting)

The name is a direct take off of Hibernate since it provides very similar functionality for Object Relational Mapping.  It is not, however, a port, emulation, reimplementation, or imitation of it or any other specific ORM/Persistence abstraction out there.  This is all new code from the ground up, with the project started in the last half of July 2009.

The premise is simple: having written a significant amount of database-centric code over the years, in a variety of environments and in several different development languages, I have come to understand what I feel are the basic features every good database abstraction should have in order to be genuinely useful.  I have very frequently been without those features, and spent a great deal of time re-implementing and refining them in each of the different environments in play.

By doing this so many times over I have realized that, for a well defined (preferably 3rd-normal) schema, the feature set can be deterministically derived.  In order to test that theory, and potentially save myself an inordinate amount of tedium and re-invention in the current employment-selected language, I have written Torpor (though not until after thorough examination of other potential offerings, which I found to be thoroughly lacking and usually tied to other larger frameworks which most certainly did not meet my needs).

There are a few features left to do before the code will be packaged for distribution under the 0.9β release, which should be available in the next 1-2 weeks.  This beta release will be for MySQL only, and while it's been coded with PHP 5.1.0 in mind I can't guarantee full compatibility with less than 5.2.8 (have not yet tested it with the target prior version).  SQLite and Oracle adapters won't be far behind, but Oracle probably won't be making use of the OCI bind variables yet - though this is definitely planned for a later release

Features in a nutshell:

  1. Configuration is controlled via straightforward XML (produced in large part by a helper script).
  2. Objects have rich accessor and mutator interfaces with just-in-time fetching and optionally selective publishing.
  3. Objects are capable of acting as intelligent factories for other related objects (and sets of objects), allowing for simple and powerful code for navigating from one portion of a database to another (intrinsic deep-loading, even in data engines lacking explicit support for foreign key relationships).
  4. Full support for associating related un-published objects, with optional (on by default) cascading publish of dependent objects (deep-saving) - useful for those tables whose primary keys are generated on publish.
  5. Full support for multi-column keys, multiple unique keys (with or without multiple columns), and multiple reference relationships between similar object types (e.g., a User may act as both a Seller and a Customer on an Order and be accessed as each in turn).
  6. Extension of provided primitives is supported and encouraged, with event-based call-back hooks and a hierarchical overload/override scheme that's easy to configure.
  7. Custom SQL support for Load, Publish (optionally differentiated by insert vs. update), Delete, including stored procedures and pseudo-bind variables (SQL placeholders filled by order of occurrence and/or named variables).
  8. Criteria based select, optionally using arbitrarily nested AND/OR collections and a rich set of criteria types and controls (including custom SQL) with support for automatic joins to related tables.
  9. Intermediate read/write -through caching interface support (can be used in distributed network based cache settings, such as memcache, for nearly-free lateral scalability).
  10. Fully extensible and customizable.

That's a pretty big nutshell, and it's not anywhere near complete.  There are just a couple gaps between this list and the current revision (no. svn:35 as of this writing) on both sides: a few features which need better testing and a little internal wiring, and some features provided but not listed.  Eventually the full user documentation will fill in the gaps, but so far this list and the actual available feature set have a > 90% overlap.

Implementation example snippet:

// Singleton context; support for instance-context
// and automatic config loading also available.
Torpor()->initialize( "myconfig.xml" );

$user = Torpor()->getUserById( 12345 );

$orderHistory = $user->getOrderSet();
foreach( $orderHistory as $order ){ /* ... */ }

$order = $user->newOrder();
$order->setSeller( Torpor()->getUserById( 54321 ) );
// OR $order->setSellerId( $user->getUserId() ), etc.
$order->setPurchaseDate( date() );

$product = Torpor()->newProduct();
$product->setName( 'Something Pink' );
$product->setUnitPrice( 49.95 );

$orderItem = $order->newOrderItem();
$orderItem->setProduct( $product );
// causes $product->publish(), $order->publish() cascade:

Code is available now via Google's project hosting: Torpor: Persistence Abstraction for PHP

Feel free to poke around, make contributions, revisions, remarks (snide or otherwise), and generally check it out.  The official beta release will be announced here with great fanfare and tremendous sighs of relief, followed shortly by the tension of worrying whether it's good enough and trying to polish user-docs.

Update (2009-08-28 09:16)

Torpor has been submitted as a potential topic of discussion for the Utah Open Source Conference 2009, October 8th-10th! This is a rather late submission, so your votes will count to help get this one on the board!


Middling MIDI

About 12 years ago, while playing around with a friend's recording studio equipment, I had a chance to try out a Casio DH-100 - "DH" for "Digital Horn."  Basically a small saxophone-esque MIDI controller in the Electronic Wind Instrument (EWI, pronounced EE•wee - not especially dignified) category.  I was astounded at how, with the simple addition of air-pressure sensitivity, the possible range of expression increased so significantly.  Furthermore, that this could be mapped through other MIDI controllers or patch banks in order to play nearly any instrument in this fashion (though not all accept the full range of expression very gracefully).

I was hooked, but couldn't do anything about it.  My budget at the time was less than meager, and I had other factors of budding bachelorhood to attend to.  I kept the idea in the back of my mind, every now and then checking on prices for used Yamaha WX-series wind controllers but otherwise simply sighing it off and going back to other things.  I was happy enough to have our Alesis QS 8.1 keyboard which I'd been introduced to about a year after the first EWI, and which Rachelle and I bought shortly after getting married on account of A) it's cheaper than a piano, B) easier to move up and down stairs (we were living in a 3rd floor apartment), and C) can be used with headphones.  At least, those were the official reasons: the prevailing one for me was the re-enactment of the classic Wayne's World "Oh yes; it will be mine..." scene I'd done when I'd first played one.  That, and how much possibility was potentially held within good studio equipment for the eager practitioner.

This was our musical mainstay for nearly 10 years, through 2 apartments and into our 2nd home (where we are now).  We were fortunate enough to "store" my aunt's old upright piano for a while, and enjoyed it immensely, but had to make other arrangements while we were trying to sell the house, returning it to its rightful owner who by that time had space for it.  During this time, in order to keep the place in a state of perpetual showability (or within 5 minutes of), Rachelle even had to keep the keyboard stashed away, and I didn't have room to take it with me up to Washington.  I did eventually make this all up to her by the way, with my "I'm so very very sorry for everything" / "welcome home" present: Her Baby Grand.

So then, we found ourselves mostly tuneless, at least of our own making, for many months while we were unwillingly separated and trying to make the best of our situations.  I briefly toyed with getting the flute out of storage (packed away in Utah), but I wanted to be a good neighbor - especially in the 2nd apartment I had in Seattle, where walls/ceiling/floors were as thin as they could be and still maintain structural integrity.  The keyboard still wasn't an option, since I didn't dare trust it to anyone to ship it nor could I very well bring it back with me from one of my visits, so I returned to the EWI idea after having a Homer Simpson Tom Landry's Hat moment: "I can't buy that. Only management-type guys with big salaries like me can afford things like that. [gasps] Guys like me! I'm a guy like me!"

I purchased an Akai EWI USB controller - a fairly cheap but eminently capable device, so long as you have a machine to hook it up to.  Which I did, so I did, and it was.  I used it to pass the time and play sad songs, practice scales, and improv along with classical music.

Now, whether or not the device is capable, it still relies on whomever is playing it to do anything worthwhile.  I don't know that I pass - I would like to think so, but I know I'm still a crude amateur next to any kind of real musician.  I offer a few samples below, which lose a little in translation through the tracker back through the VST filter from the original performance, but it's close enough (yes these are all me, and I'm sorry they're all me):

What's interesting is what prompted me to finally record at least a little bit of this.  I have other music projects under way (and geek projects), and have been letting the EWI gather dust since shortly after I returned from Seattle, but upon hearing yet another phenomenal cello performance in the background track of something or other wondered to myself... "How much does a cello cost, anyway?"  And have found myself once again bit by another instrument bug (there are more than just these 3, too).  The thought has even crossed my mind of making a steampunk style electric cello myself, in order to have something to play and practice extensively without offending others (works well with headphones), because steampunk is fun even if it is getting a little too close to mainstream, and because it would be musical and geeky at the same time.  I'd even make an interchangeable fingerboard, one with and one without frets, in order to support different styles of performance (or lever-actuated retractable frets, but imagination needs to give way to reality in terms of practical implementation sometimes).

I whipped out the EWI, set the VST to cello, and started playing that instead.  Maybe someday...


April 2014
« Sep    

Recent Posts