What is APIE?

Since writing this article, I have rewritten it in much more detail.

If you have any experience with Object Orientated Programming (OOP), you’ll of probably heard of APIE. If you haven’t, then quite simply APIE is an acronym for the 4 most important concepts of OOP.

APIE stands for Abstraction, Polymorphism, Inheritance and Encapsulation. Each of these are huge subjects in their own right and together form what is know as OOP. Below I aim to explain the basis to each of these concepts, focusing on what they mean, when they should and shouldn’t be used and how you should go about writing code, with them in mind.

Continue reading →

Master MySQL Joins

MySQL is such a mistreated language. It’s almost as if all we want to do is SELECT INSERT and UPDATE stuff. Ok thats what we want to do 99% of the time, but that other 1%, you can do some pretty cool things with (If you’re a geek).

Now I bet you was hoping I would teach you how to fight aliens with MySQL, but instead I’m going to talk about joins. Joins sure as hell aren’t amazing, or revolutionary, but I bet, whether you are a newbie or a seasoned pro, there will be something you can learn from this article.

Continue reading →

PHPUnit testing singleton dependencies

Unit testing should be simple, but when you have a code base which uses static methods, singletons and a lack of dependency injection, you can run into some serious problems.

The key to writing maintainable and testable code is dependency injection. Without dependency injection, our objects have to rely on systems that may or may not be under our control. We want our unit tests to be executable in an environment which does require a database or a file system or another systems API etc. Dependency injection allows us to provide mocks of these external and frankly irrelevant sources. The mocks will simply tell us what we want to hear and then we can test our own system with this data. Normally we would use PHPUnits getMockBuilder method to create mock objects, this however cannot be used in the case of a singleton for a few reasons:

Continue reading →

500 The FastCGI process exited unexpectedly

Recently at work, I’ve came across the error “500 The FastCGI process exited unexpectedly” error code: 0xc0000005, trying to execute a PHP script on an IIS6 and IIS7 server. Knowing how annoying it was to resolve and how many people have the same problem, I thought I would answer your questions.

The problem is caused by excessively requiring more memory than is allocated to your script, which depending on the version of PHP you are running, defaults between 8 and 128 megabytes. To work out how much memory your script is actually using, you should log usage at all points in your script (especially in large loops), this can be done using the functions:

Continue reading →