talideon.com

Blackout Ireland

February 1, 2006 at 1:30AM How Syncope Works

Here’s how Syncope, the kinda-but-not-really-a-framework I mentioned before, works. It’s really just a library with a bunch of canned request lifecycles. Those are the only parts of it that vaguely resemble a framework. It’s made to be as simple and unobtrusive as it possibly could be. If you don’t like the way some part of it works, you can swap it out for something that suits you better.

It doesn’t try to be like Rails, Django, or anything like that. They’re fine, but the way in which they work doesn’t really fit well with PHP. I really don’t understand the ongoing Rails envy PHP developers have [1, 2, 3]. The whole point of Syncope is to play to PHP’s strengths.

Overview

The core of it is the Pipeline class, which takes some bit of data (string, array, object, it doesn’t care) and runs a bunch of filter objects on it. The only requirement for a class to be a filter is that it have a method called execute(), which takes the pipeline object and the data being passed along as argument and calls donext() on the pipeline to execute the next filter on the pipeline.

Web Lifecycle Outline

The filters starting with Simple are just that: simple versions that work as simply as possible, almost moronically so. For example, the view code uses plain old PHP templates and the request filter just ensures that the action parameter is well-formed and implements an IE workaround to emulate a lot of the <button> tag’s functionality with multiple regular <input> buttons.

Other Bits And Pieces

In addition to the above, it also has an XmlBuilder class I wrote a while back to make building feeds and other XML documents less painful for myself. Using templates for them doesn’t make an awful lot of sense to me unless there’s no better way to do it.

There’s also a bunch of helper functions covering a bunch of things I keep on having to do in templates and elsewhere.

Stuff To Do

While the stuff outlined above covers a lot of the annoying boilerplate I’ve ended up writing in the past, there’s a few ancilliary things I’d like to add to the library.

Things that would be important if others wanted to use it would be:

What I’m not going to do is write yet another ORM library. The fact I’m writing a library like Syncope at all is bad enough. [wink]

Update: I forgot to mention that code for caching HTML fragments (or anything like it) is also something I’m intending on writing. I just have to figure out how exactly to handle the dependencies between the various fragments.