Drupal 8 Messenger Service

7th February 2019

For a long time the drupal_set_message() function has been a mainstay of Drupal development. You can use this function to print a message or an error response to a user. This is useful to do as it can be done almost anywhere before the final page rendering functions and will be printed into the same area of a Drupal page.

PHP:CSI - Random Increment Insert

26th January 2019

A while ago I was working on some changes to a website and came across a block of code that made me stare blankly at my screen. The website I was working on was a custom build website, created by another developer at the company I was working with at the time. I have never done a PHP:CSI on this site before but remember being so amazed at what I found at the time that I made a note of it for future reference. I have pondered recently how to approach the analysis of the code.

Image Colorising In PHP

14th January 2019

Colorising images is fairly simple to accomplish, especially using PHP's GD library. All we need to do is load an image, create a blank image of the same size in a particular color and then merge the two images together.

In fact, we can do this entirely with the imagecopymerge() function, but creating a function to wrap all of this makes sense as well.

Drawling A Line With Pixels In PHP

13th January 2019

From the drawers of "I didn't realise how complicated that was" I was wondering the other day how to draw a line using just pixels. This turned out to be more complicated than I thought.

Normally in PHP you would use the imageline() function to draw a line between two points. The following block of code creates and image and draws a white line from the coordinates 50x,50y to 200x,150y.

Checking Domain TTL Values

4th January 2019

Part of the process of putting a new site live can be moving DNS entries around. Prior to doing this it's a really good idea to sort out the Time To Live (TTL) of the DNS record so that when you do change DNS entries you aren't waiting around for a day for the DNS to sort itself out. Most DNS registrars will allow you to set your TTL down to a minute or so.

It's also very important to check the status of your DNS records to ensure that they have the correct TTL, usually a day before (and day of) the move.

Read Contents Of SSL Cert From The Command Line

4th January 2019

Whilst it is possible to view the contents of an SSL cert from within most modern browsers I occasionally find the need to use the command line to find out the same information. I find this useful when renewing certificates as browsers can occasionally cache certificates for longer than expected, causing false results.

The following command connects to the server, downloads the SSL certificate from port 443 and then uses the openssl tool to extract the information from the certificate into a readable format.

Color Sorting In PHP: Part 4

2nd January 2019

Following on from by previous post about sorting colors I decided to take another step towards sorting colors by segmenting the data to create a further dimension to the multi-dimensional array.

The array is already split into segments based on the hue of the color, but we can further split this by separating out saturation and value into separate arrays within hue. To do this we set the saturation or value to be a constant and push them into separate arrays.

Color Sorting In PHP: Part 3

1st January 2019

The last time I looked at sorting colors I had produced a nice band or sorted colors, but to do so I had essentially removed a third of the data from the color information. This meant that there was no white or black colors in the band of sorted colors.

Drupal 8: Repairing A Broken Multi-Site Configuration Setup

4th December 2018

I recently wrote a post about setting up a multi-site configuration setup using the Configuration Split module. That post was written after I did research into how to set up configuration splits and use them to create multi-site setups in Drupal. One thing I realised when doing that research was that although it's quite easy to get setup with that kind of setup, it's also easy to get it wrong and create a setup that really doesn't work.

Drupal 8: Multi-Site Configuration With Configuration Split

2nd December 2018

Setting up a Drupal 8 site for a multi-site environment with a common configuration isn't too hard, it just requires a little bit of forethought and some planning to get things right. You need to have a default configuration in mind, and then think about how each site can override this configuration in different ways. I have seen it done wrong a few times recently and once you go down the wrong path, getting things back in line again can be a difficult.