How I use WordPress and Docker Compose

It’s a cold Friday morning with the struggling sun doing its best to blind me with glare. That can only mean one thing:

The weekly CodeReviewVideos fun-filled newsletter.

(insert your own party popper sound effects)

This week saw three new videos added to the site.

#1 – [Part 1/2] – WordPress and nginx with Docker Compose

WordPress gets a lot of hate.

There are some valid reasons to nag on WordPress, but they are the same reasons you could nag on Laravel, Symfony, or Rails (or *insert any other framework / language here*).

Primarily the cause of problems with WordPress are *drum roll* People!

Specifically: developers.

Yes, PHP has a super low barrier to entry.

And yes, that means many take their first steps in coding by adding functionality to a tool they already use. In this case, seeing as WordPress apparently powers ~25% of the web, it’s unsurprising that many of these first steps happen within the WordPress ecosystem.

With that said, there are plenty of reasons why WordPress is a tool I often reach for. The big one is:

WordPress stops me from reinventing the wheel.

Also, paying clients love it.

Most any site I create will have some WordPress functionality.

Also, most any site I create these days has Docker in there somewhere.

In this, and the next video we cover one way you could use WordPress with Docker.

The kicker here is that this is not true to the spirit of containerisation.

Why not?

Well, WordPress and all its plugins and themes tend to update at a rapid pace. If each time a plugin or theme or WordPress itself needed updating, I would spend most of my working week keeping up to date, then packaging a new image, then uploading it, and so repeats the cycle for every point release.

No thank you.

Instead, I opt for a different approach. And that’s what we cover in this video.

#2 – [Part 2/2] – WordPress and nginx with Docker Compose

This video continues on from the previous.

We’re setting up WordPress with nginx as our web server, and a MySQL back end. All of this is managed by Docker Composer, because life’s too short to do all this by hand.

We make use of environment variables in this configuration. And these are great in development / test / staging environments.

However, in production I tend to not use environment variables. We’ve covered why that is as part of this series already.

In this video we cover a way to easily switch out our wp-config.php file depending on the environment we are in.

This not only means we can make use of environment variables in development and use the hardcoded, classic approach in production, but also that we can keep our WordPress ‘core’ files completely isolated from our config.

Hey, it works for me.

#3 – Better Strings (Template Strings)

I get asked about JavaScript more than pretty much anything right now.

There’s a lot to cover.

In this new series I’m trying something a little new:

We’re going to look at some PHP code. And then some ES5 code. And then some ES6 code.

In each case we are going to (try to) achieve the same thing. Often this won’t be possible, but seeing an example you already know how to do in PHP, or ES5, will – hopefully – make the transition to ES6 that much easier.

In this video we start with template strings. This is probably the most gentle way to introduce yourself to ES6, and we will continue to use template strings in many examples throughout the rest of this series.

As ever, I’d love to get your feedback on this course.

Next Conference

I love attending a good conference.

You can read all my past conference reviews by clicking here.

The next one I will be attending is PHP Yorkshire. At the time of writing there’s 12 remaining tickets at the super early bird price of £78. That’s fairly fantastic value for a conference ticket price, so if you’re in the area, consider grabbing one before the price hike.

When I got mine there were ~28 remaining, so these tickets are selling.

As ever, if you are attending then please get in touch as I’d love to meet up 🙂

Ok, that’s about it from me. Have a great week, and happy coding.

Chris

 

Published by

Code Review

CodeReviewVideos is a video training site helping software developers learn Symfony faster and easier.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.