Anyone who has done any development with PHP will be familiar with the infamous White Screen of Death; a blank browser window indicating that something horrible has gone wrong. A common cause, for me at least, is making a method call on a null object – easy to do in an object oriented architecture.

The exact reason as to why your script has gone splat will be reported in the log file, but from a UX standpoint, giving a blank screen to your customers is far from ideal. It is particularly problematic in complicated platforms like Elgg and Known, which use output buffering and have a plugin architecture.

Here’s a quick bit of code which can catch many (all?) of these fatal errors, and at least echo something. A variation of this is already in Known. Place the code somewhere towards the start of your script…

Hope this is useful to you!

Here is the latest in a series of libraries I’ve been releasing which package up some of my often used, cut and pasted code, into reusable modules for myself and others to use.

So here is the companion piece to my previously released Web Services client library, a web services API endpoint library.


The library allows you to expose a Callable type (function, object method or static function, closure, and call it via a built in Simple Page Handler endpoint that you can attach to a virtual page (e.g.

The library will then use reflection to extract the required and optional parameters, and any default values to pass, and then pass them accordingly.

Once the code has run it’ll trigger an event which you should listen to and determine what format to output the results in based on the 'format' parameter. You might want to look at the Simple Template Library to help you here!

I’ve written an example handler that exposes a single API, but feel free to fire over any comments or questions!

» Visit the project on Github…

As with the code I’ve released previously, I have found myself cutting and pasting this code about the place again and again, so I’ve packaged up my simple PHP template framework and stuck it on github.

This library comes complete with a basic HTML5, JSON, and JSONP templates, that you can extend and override, making the development of web applications (hopefully) slightly easier. It does for me at any rate, because I really hate repeating myself!


The default template engine provided by this library – the Basic template – should be fairly familiar to anyone who’s used Elgg or similar systems.

You initialise it with a set of template base paths (“base” provides a basic HTML5 hierachy). If you pass an array to the constructor, each array overrides the one preceding it, and so you can replace some functionality (for example providing a bootstrap layout) without having to replace everything.

Views are in a file hierarchy off of [basepath]/[template_type]/path/to/view.php, and are named simply as the path without the base gumph (in the example I give in the docs, this view would be ‘path/to/view’).

HTML5 versions of pages are in the /default/ template type branch, but the basic template comes with json and jsonp encoding of the pages, you can specify which template to use at runtime by passing the _vt=[branch] variable on the GET line, or from within your program code.

The basic template also makes a call to the simple event dispatcher before and after a given view is generated, passing “view:[viewname with colons instead of slashes]” as the namespace and either “prepend” or “extend” as the event, together with an array of all the variables passed to the view.

So, to listen to my documented example, you’d listen for events on “view:path:to:view” and either “prepend” or “extend”, echoing any extra stuff you want.

Anyway, hopefully this’ll be useful to someone!

» Visit the project on Github...