Software Engineering in WordPress, PHP, and Backend Development

Author: Tom (Page 112 of 428)

The Repository Pattern Primer

Whenever you’re working on a larger project that’s based on WordPress, the odds that you’re going to be working with more than a single data source – that is, the WordPress database – are higher than normal. For example, you may be working on a project that has to coordinate information from:

  • the WordPress database,
  • a help desk ticketing system,
  • a content importing system,
  • another third-party API,
  • and possible more.

And when this happens, it can become a bit cumbersome to write code that makes it easy to retrieve information from those different places. This what developers usually talk about when they refer to dealing with “layers” in their application. That is,

  • there are layers for presenting information to the user,
    layers for handling business logic (or domain logic),
  • layers for communicating with APIs,
  • and layers for storing data.

Honestly, you don’t have to have a variety of data stores to watch to create a layer that makes it easier to send and retrieve data from the database, that’s just when it’s more common. You can just as effectively work with a single data store, like the WordPress database, when implementing the repository pattern.

Regardless, if you’re building a larger website, web application, or plugin, implementing the repository pattern is something that can pay dividends in maintenance, clarity of code, and separation of concerns.

But how might this be implemented within WordPress? It’s not terribly challenging, but first, it’s worth reviewing a repository primer before jumping into any code.

Continue reading

Managing Work on Vacation (Managing The Tension)

Two weeks ago, I was on the first major family vacation my family, and I have taken since we’ve had kids. This isn’t to say we haven’t taken trips, gone to the beach, and things like that but we haven’t done anything quite like this.

In short, we spent a week at Disney World – and that’s fun, sure – but when you see it through the eyes of a five-year-old and a three-year-old, nothing can top it.

Managing Work on Vacation

My girls seeing the Magic Kingdom for the first time.

And it’s not even that I’ve never been there before, you know? It’s when you go and experience all of the attractions with your kids who have seen all the Disney movies, cartoons, etc., and then getting to see things like that come to life.

The purpose of where I’m going has doesn’t really have to do with the details of our trip. Yes that was fun and yes I’m glad I went, and we’re already talking about going back before our youngest is too old to get into the magic that comes with visiting the place.

But there’s a whole thing about trips like this that are directly related to balancing work-family-life, right? Ultimately, it has to do with managing work on vacation and the tension that comes with it specifically if you’re self-employed (because that’s what I know).

I doubt I’m going to share anything new, but I thought it might be worth sharing my personal take on what it was like to completely disconnect for a week and what it was like coming back to all things waiting.

Continue reading

How To Make MySQL Globally Accessible (From MAMP)

I recently walked through how to make WP-CLI globally accessible across your system (assuming you’re running macOS or a variation of Linux).

I’ve also talked about various things as it relates to using MAMP Pro for WordPress development. Naturally, one of those tools is also MySQL; however, it’s one that is often treated as a “set it and forget it” application.

But I’ve recently started working on a project that requires a bit of automation as it relates to syncing the development and the staging databases. And since this is scripted, it assumes that MySQL is globally available.

If the only way you’ve installed MySQL is via MAMP (or perhaps another similar package), then you’ll likely need to make MySQL globally accessible on your system.

Here’s how to do that.

Continue reading

Mindset For Debugging (And Why We Need It)

When it comes to writing software, maintaining software, or simply trying to understand software, a debugger is one of the most powerful tools that we can use.

But when it comes to WordPress, it seems that it’s less common. Personally, I’m not sure why:

  • I don’t know if it has to do with the nature of open-source,
  • if has to do with the convenience of echo and var_dump that are built into the language,
  • or if I’m just missing other developers who talk about it.

Regardless, if an IDE doesn’t have a built-in debugger, it’s not too difficult to set up Xdebug and get started using it. And once you do start using it, you learn much more about how a given piece of software performs regardless of if you wrote it or if someone else wrote it.

Yes, I’ve written on this topic before, but I recently stumbled across an article that I found to be a really good break down of how to shift one’s thinking into a mindset for debugging.

Continue reading

Hitting Pause on Publish

Whenever there are holidays, I still publish a post about what’s going on simply because this blog has become a little more than just a place to talk about code. It’s also a place where I very occasionally share what is happening offline.

This week, my wife and I are finally taking a week-long trip with our daughters.

And we’re stoked.

Continue reading

« Older posts Newer posts »

© 2025 Tom McFarlin

Theme by Anders NorenUp ↑