With PHP5 being officially released over a month ago, I think it’s about time to get some PHP5 software reviews online. Today, we’ll look at “Sourdough”:http://sourdough.phpee.com/, a PHP5 application framework.
Sourdough uses “coWiki”:http://www.develnet.org/ to power its site. With an increasingly large number of sites using coWiki, I’m pretty sure I’ll be reviewing it next.
Sourdough has created its own database abstraction layer. Today, database abstraction layers are a dime a dozen in the PHP world. However, since the PHP5 field for these is still a bit slim, I wont complain about that too much.
Sourdough is based on the Flyweight Pattern, which I found quite interesting.
bq. The Flyweight Pattern uses sharing to support large numbers of fine-grained objects efficiently. A flyweight is a shared object that can be used in multiple contexts simultaneously. The flyweight acts as an independent object in each context — it’s indistinguishable from an instance of the object that’s not shared. Flyweights cannot make assumptions about the context in which they operate.
This is a design pattern not yet seen in the world of PHP application frameworks. That’s quite refreshing. Unfortunately, the implementation of this pattern is not quite right. One look at the “API Docs for the Sourdough class”:http://sourdough.phpee.com/api/sourdough/Sourdough.html should show you why.
While this Flyweight Pattern is certainly implemented, it’s done in a static fashion. That is, each object type that that Flyweight is capable of obtaining is statically defined in a method within the Sourdough class. This means that altering what it can serve requires editing or extending the Sourdough class. This would have been better served in a dynamic fashion using PHP5′s __call() overloading mechanism or through the implementation of a single method to retrieve objects along side a configuration file, or well designed directory structure.
Because of this static implementation, the quirks of each different class being handled are all worked out within the call to the method that instantiates the desired object. With a dynamic implementation, a Flyweight interface could be created to allow any class that implements that interface to be served by the Flyweight Factory.
Despite that, a look at what the Flyweight provides gave me enough information to conclude the review. There is a method to retrieve configuration information, as well as methods to obtain various objects. These objects are nothing new, and in some cases, a step in the wrong direction: Auth, BBcode, Db, DirScan, FileConvert, FormMail, Forms, Html, Image, LineCount, PatForms, PatTemplate, Session, Settings, SqlHelper, Template, User, Xslt, and Yabd. There is nothing special or unique in this list: no application server, no object persistence, no object to URN mapping, no advanced logging capabilities, no error trapping/handling.
Therefore, in conclusion, Sourdough is really a mish-mash of already available components and libraries, all served up by a single, statically implemented, Flyweight Factory. A decent idea, but poorly implemented with nothing new to earn it any credit.