Consistency is key

A side effect of using a tool to generate build configuration files with templates is the consistency that it introduces.

The majority of my projects use a PHP-FPM or PHP CLI container. In my Docker Compose file, the service was mostly named php but sometimes it was php-fpm. In the templated file, it's always named php.

Some projects would use mysql or mariadb for the database service and nginx or caddy depending on which server was being used. These are now always database and web respectively.

As well as being easier to switch between projects and not having to think about which names are used in each codebase, it's also much easier to write tools and automation when the names are consistent.

For example, I'd always write a long-ish command to import a database file - reading and unzipping it, and importing it by connecting to the database running in its container. The command would essentially be the same with slight changes based on that project - such as the database service name.

Now the command is the same for all projects, and I can automate it by writing a script that works on any project meaning I no longer need to write the long command at all.

- Oliver

P.S. Need help or want another pair of eyes on your code? Book a 1-on-1 consulting call or an online pair programming session with a 100% money-back guarantee.,

Was this useful?

Sign up here and get more like this delivered straight to your inbox every day.

About me

Picture of Oliver

I'm an Acquia-certified Drupal Triple Expert with 17 years of experience, an open-source software maintainer and Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.