By Harry Fuecks

A taste of projects to come with PHP5

By Harry Fuecks

Just drawing attention to some interesting projects written specifically for PHP5.

First up is cowiki which, despite being only on release 0.3.x, has already proved a hit and powers the phpCommunity site. The code is very well organised, packed with patterns and it’s clear the author knows Java. There doesn’t seem to any reliance on other PHP libraries so wheels are getting re-invented but, as such, it makes an interesting study for anyone looking for tips on how to put PHP5’s new features into use. It’s a little too Java inspired for my taste for example there’s a base class “Object” – for thoughts on those lines read PHP Application Design Concerns. Each to their own of course and perhaps having some additional abstractions built in helps while PHP5 itself is still a moving target.

Another two interesting projects can be found over at

First is Creole, a database abstraction library written specifically for PHP5 and modelled after Java’s JDBC. This will definately pull a Java crowd and the code is, again, very well organised. Here’s a sample of connecting performing a query;

$dsn = "mysql://dbuser:dbpass@localhost/testdb";

$conn = Creole::getConnection($dsn);

$rs = $conn->executeQuery("SELECT id, name FROM users");

while($rs->next()) {
echo $rs->getString("name") . " (" . $rs->getInt("id") . ")n"

I get a bit edgy about methods called things like getInt() in PHP. Also I wonder about modelling after JDBC which (my opinion) places too much emphasis on “exceptional” cases (Java being a general purpose language after all) as opposed to being focused on making common cases as easy as possible (dumping a SELECT into an HTML table is a common case in PHP).

By contrast, WACT’s DBC (Database Connection manager) API makes fetching a result set (including connection to database, connection settings stored in an ini file) is reduced to;

$DataSet = & DBC::NewRecordSet('SELECT id, name FROM users');

while ( $DataSet->next() ) {
echo $DataSet->get('name') . " (" . $DataSet->get('id') . ")n"

And getting a paged result set looks like;

$PagedDataSet = & DBC::NewPagedRecordSet('SELECT id, name FROM users', $Pager);

Where $Pager is an instance of a “paging component”.

Anyway, such concerns aside, the other project on is Propel, an Object Relational Mapping tool based on Apache’s Torque (Java). Once your mapping layer is built, it allows you to be blissfully ignorant of SQL (and underlying database abstraction layers) and deal purely with objects. The above examples might become;

$Users = UserPeer::doSelect();

foreach($Users as $User) {
echo $User->getName() . " (" . $User->getId() . ")n"

One final project, which you may run into while trawling the Propel documentation is Phing, a build tool for PHP which has much in common with Java’s Ant. That anyone would want to write an Ant-like build tool for PHP (which is already into 2.x version numbers) is a sign that not everyone agrees with the principle that PHP = small web sites only…

These last three projects are coming from developers related to the Binary Cloud I believe, a PHP framework project I wish would expose itself more to the light of day (a select few rave about it while the rest of us hunt for the “Download” link…).

So positive signs of things to come. If more PHP projects follow this kind of lead, then the promise of PHP5 being “Enterprise Ready” will become a reality.

The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account