BOEUF Filters

November 4, 2007

BOEUF (Bunch Of Extremely Useful Functions) is my own “mini framework” for building web applications. One of the coolest new features I’ve been able to add to it recently are filters.

Filters are functions that are attached to any of the 4 basic actions - create, read, update or delete. You simply create a function called “f_update_post” and that function will be called every time the table “post” is updated. BOEUF evaluates filters after the entity relationships (e.g. “a comment belongs to a post”) are processed into an associative array and get their single argument (which is the whole array) by reference so they can be extremely powerful. Filters can also return values, which override the corresponding CRUD function’s own output.

As an example, I used filters to get rid of spam on this blog. I just created a function f_create_comment(&$data) which checks if the given full year is indeed the current year and then acts accordingly. I only had to add that single function, not touching any other part of the app.

The service management system I’ve been developing at work uses filters extensively for anything from time-stamping orders and sorting repairs to notifications and handling file uploads.

Not sure why the heck anyone else would ever care about this, but there it is. :)