Thoughts, tutorials, tips and tricks for web and mobile development

How to put your Docker image on a diet


I recently delivered a presentation at PHP South West about how to put your Docker image on a diet. The talk mentioned six points that help reduce the size of a Docker image.  The majority of the points focused on improving the Dockerfile and the last point was based on using a .dockerignore file. This post […]

How to rename a WordPress URL in MYSQL


This is how you can rename a WordPress URL using a SQL script. This can also be done against a Docker container.
The script requires two variables to be set. The first is the old site name and the second is the new site name.  I’ve included some examples of how to set and pass these variables into the SQL file.

Don’t prioritise controller testing over unit testing

There are lots of types of tests that programmers should perform, unit testing, functional testing, integration testing etc… Often I hear programmers confuse controller testing with unit testing. They see that a functional test offers more code coverage and so they focus on controller testing instead of units of code.

CSS classes in Symfony2 twig labels

Symfony is a PHP framework

A quick PHP tutorial showing how to apply css classes to a Symfony 2 label when rending a twig template. The demonstration covers the differences between rendering normal form controls and labels within a twig template.

In short the label attribute is called label_attr and the field attribute is called attr.
Both can have the same available parameters but the label attribute must be the third parameter of the label control

How to remove a stale PID from a Docker container


Sometimes my Apache 2 Docker container refused to restart because the previous Apache PID was active.
The error I got was httpd (pid 1) already running in the docker container. Usually this happened after docker-machine refused to shut down properly or the Docker container stopped unexpectedly.
I got around this by writing a simple script that removes the stale PID files from the apache2 Docker container upon startup.
The script has been working without issue for the past month so I’ve decided to share it.