Image for post
Image for post

As a fledgling programmer you’re bombarded by commandments telling you what’s considered right programming and wrong programming. These edicts can seem very useful and on the surface seem irrefutable. But if they are applied without deeper thought they can do more harm than good. One of the worst offenders is ‘thy code shalt have abundant comments’. Another questionable one is the DRY principle.

‘DRY’ is an acronym meaning: Don’t Repeat Yourself. It is often interpreted to mean there should be no similar blocks of code in a codebase. And certainly no copy-pasted code. But in my opinion this interpretation is too broad.

This article summaries a solution to the problem of calling and listing commands in when at least one of the commands is not instantiable.

The problem

By default, Symfony will instantiate all your application’s commands when initialising. If just one of the commands fails to initialize, the entire application will fail — even when executing a command that works fine.

Ordinarily, this shouldn’t be a problem. After all, classes should be instantiable, shouldn’t they? But, in my work at Funeral Zone, we have a use-case of a console application that sits in multiple microservices. Some of the commands in the application are reliant on environment variables (such as database credentials) that are not necessary for all microservices. …

This article is about convenient and safe mutations of composite that implement the .

Here’s an example of a composite value object. It’s a user that has two subtypes: an email address and a name.

final class User
private $emailAddress;
private $name;
public function getEmailAddress(): EmailAddress
return $this->emailAddress;
public function getName(): Name
return $this->name;
public function withName(Name $name): User
$native = $this->toNative();
$native['name'] = $name->toNative();
return self::fromNative($native);

To mutate the name of a User you take an existing object and call the withName method on it. This method returns a new instance of User where all the previous values are the same, but name is now set to the new value. …

In this article I explain why I’ve grown to accept trailing commas in code. Consider the following two examples:


$characters = [


$characters = [

Which one looks neater?

Personally I think B is neater. It’s also grammatically correct. The list does not continue after ‘Garak’. I’ve coded arrays like this for years.

The JSON specification gave me added justification. does not allow trailing commas. This was for browser compatibility reasons. It’s also faster to parse.

But recently I’ve been persuaded to let it go (🎶). Apart from being prettier (to me) B has no practical advantage over A. …

I’m going to share a few optimisations you can make to speed up composer installs in Docker builds.

  1. Prestissimo
  2. Turn off Xdebug
  3. Composer install before codebase

1. Prestissimo

is a spiffing plugin for Composer which parallelises all the downloads. You just have to install it to see sometimes large speed increases — no configuration is needed. Installing it locally is simple as:

composer global require hirak/prestissimo

To leverage it in a Docker build, install Composer in your Dockerfile with the following:

RUN curl -sS | php && mv composer.phar /usr/local/bin/composer && composer global require hirak/prestissimo --no-plugins --no-scripts

2. Turn off Xdebug

Composer runs much quicker with Xdebug disabled. Many Linux distributions have a CLI command called phpdismod. You can use it to disable Xdebug in your Dockerfile. …

At Funeral Zone, we’re into . We’ve been writing value objects in PHP for two years but have recently refined our approach. This article explains our philosophy behind implementing value objects in PHP 7.

We’ve open-sourced our on Github.

Quick introduction to value objects

A value object is a concept from Domain Driven Design. They are objects whose equality is not dependent on identity.

$location1 = new Location(1.2902, 103.8519);
$location2 = new Location(1.2902, 103.8519);

$location1 and $location2 are considered equal because they both have the same latitude and longitude. The definition of a Location is purely based on its value. …

On December 7th 2017 I gave a talk at about event sourcing.

In a nutshell, event sourcing is about changing your persistence strategy to be event-centric as opposed to data-centric.

Tech Exeter is a community, conference and co-working space for tech people in .


Chris Harrison

Software engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store