This is the website of Andy Carter a PHP and jQuery web developer in the Steel City. Working with CakePHP (and a bit of Textpattern and Drupal too).

Latest Entries

Have you thought about casing?


This is an interesting look at how we use casing in our code. In his blog post Brendt argues that snake case is more readable than camel case. I particularly like this point that he makes:-

Readable code, reduces cognitive load. Less cognitive load means more memory space for humans to think about other things, things like writing business logic.

I’ve always preferred camel case over snake case, but I think that has been for purely aesthetic reasons over how easy they are to read.

A simple little trick in PHP for when you need to make sure that a value doesn’t drop below zero. For example, you might be subtracting a discount from a basket total and not want the amount to be paid to become negative.

Earlier today I got caught out by an interesting little issue when using env() to access environment configurable values on a deployed Laravel app. Despite having read through the documentation I managed to completely miss the caveat on using this function whilst caching the app’s configuration.

Constants are named values that do not change. You’ve probably used them many times to set a value that you want to persist throughout your codebase. In this short post I’m going to look at a couple of ways we can use them to improve our code. We’ll look at how they can be used to reduce bugs and make our code more readable.

Featured Entries

A Beginners Guide to Package Manager Bower and Using Gulp to Manage Components

Package managers like Composer for PHP and NPM for Node have become essential tools for simplifying a developer’s life. A package manager is a tool for keeping track of what you’ve installed, as well as installing and upgrading packages. They also check for dependencies and compatibility. Bower is a package manager for the web.

Calculate a Person's Age in PHP (Accounting for Leap Years)

I've seen a lot of code out there for calculating a person's age that makes the mistake of ignore leap years. If you ignore leap years then the age will be out by a day or more on or around the person's birthday which isn't what you want.

Latest Tweets

Follow Me