Singletons in PHP

If you’ve heard of design patterns you’ll have probably heard of the singleton pattern. It’s debatably the easiest to start with and get you on the road to becoming the Walter White of design patterns. Below I will explain what a singleton is, when you should use a singleton, rules that must be followed, drawbacks and I will provide sample code. Lets get started.

What is a singleton

As the name sort of implies, a singleton is a class that can only be initialised once per request to an application. E.g once per HTTP request on a website.

Continue reading

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

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