Author Archives: David

PHP and extensions

This week I’ve had to do some PHP work, something that is becoming less and less common as I use other languages. Part of my work required setting up some extensions for PHP. PECL is a nightmare, requiring so many development libraries to be installed (and in some cases compiled from scratch) to get the…


Read More

PRISM

PRISM, the surveillance program has been in the news a lot recently. What the acronym stands for seems to be something of a mystery, in fact Wikipedia simply calls it a “government code name”. I think I know what it means: Privacy Really IS Mythical…


Read More

Avoiding hidden form fields

Hidden fields in a form can be useful, but they can also pose a huge security risk. Take an example of a web page which allows a user to edit a customer’s details.

Using a browser add-on such as Firebug it’s very easy for a user to change the value of that customer_id field…


Read More

Asserting that an array contains another array in PHPUnit

I needed to test whether one array contained a subset of another array in PHPUnit. There’s no built-in function for that so if you have a similar need feel free to use the code below:


Read More

Ruby DataMapper aliased associations

In Ruby’s DataMapper ORM you can easily associate one type of object with another, e.g. an Image can have many Tags. For the most part DM takes care of the issue of pluralization, ie. if your tag object is Tag then the associated tag collection is accessed as image.tags However, what if you want to…


Read More

Logger version 4

I’ve updated my Flexible Logger to version 4. Changes for this version are: * split plugins into individual files * change error() to addError() to allow for a $logger->error(‘message’) method * rename underscored properties * better conformation to PSR standards * more inline documentation As usual you can clone the source from my GitHub repo…


Read More

AutoLoader version 3

I’ve updated my PHP Auto Loader to version 3. Changes are as follows: * A new index system * Improved checking of missing classes * Improved debugging * A smarter caching system * Better locking mechanism In order to better comply with the PSR standards I’ve been refactoring some of my code. As a result…


Read More

Phishers getting a free pass

Yesterday I received a phishing email with an HTML attachment. The HTML contained a form containing banking details which would be POSTed to a particular URL. (eg: http://somedodgysite.com/carddetails.php) After filling in the form with junk and posting it, I noticed that the response redirected my browser to a genuine banking page. I reported the site…


Read More

Doctrine 1 alternative

I’m working with a lot of projects that use Doctrine1. The ORM is ageing somewhat and has been criticised for its performance overhead. At my current job I have written a REST API that provides an easy means of interacting with Doctrine models, much like Ruby on Rails does. It works very well and performs beyond our…


Read More

JEditable – custom field name

I love JEditable, it’s an extremely useful way of having editable content on a page. I did come up against a limitation though. The name of the field is determined by the ID attribute of the containing DIV (or other element). Consider the following where you want fields to be editable for two different companies…


Read More