Software, Development, and WordPress

Tag: PHP (Page 1 of 10)

Using GrumPHP, Composer 2 and PHP 7.2

I’m very much a fan of GrumPHP which I’ve written extensively about in previously posts.

And as my last past alluded, I’ve been adapting a piece of software so it maximizes its availability across all platforms using PHP regardless of now new or how old the platform is (at least between PHP 7.2 and PHP 8).

Here’s the thing, though: If you’re working with an older version of PHP then you’re going to need an older version of GrumPHP and if you’re going to use an older version, you may need an older version of Composer.

Except maybe not!

Continue reading

Installing Old Versions of PHP With Homebrew

I love the speed at which PHP is moving these days and how fast the new versions are, too 🙂 but that doesn’t mean the software on which we’re going is going to consistently be able to keep up with the fast release cycles.

And that’s okay. It is part of software development and it has been since before most of us were writing our first lines of code (let alone before we were even alive). Obviously, this means that those of us who work with PHP are likely going to need to work with different versions.

Sometimes we’ll be working with the latest, sometimes we’ll working with a version or a few versions older, and sometimes we may need to work with something that’s deprecated.

And this is usually the part where certain engineers start saying we should upgrade all the things and stay with the newest version of languages and frameworks. But that’s not how it works.

What does this have to do with PHP, though?


Assume for a moment that you’re working on a project that was written with 8.0 but you start rolling it out to a suite of products. Some are running on a server with 7.4, some are running 7.3, and some are running 7.2.

Is it easier to handle all of the other software already running on their servers or refactoring your code?

A bit of a rhetorical question.

Continue reading

A Beginner’s Guide to Querying the Slack API

Creating Slack applications can be as time-consuming and complex as writing any other type of application. What if you’re interested in querying the Slack API for your workspace and incorporating the results in a WordPress plugin? Here’s how you can get started.


Ultimately, all we need to make queries to the Web API is an OAuth token and a REST API client to make requests. From there, it’s a matter of programmatically implementing the functionality in your code.

But that’s not at what we’re aiming. Instead, this article is more about learning how to make requests to the Slack API and what’s required to get set up to do so.

Continue reading

How to Dynamically Load Classes by Namespace in PHP

TL;DR: To dynamically load classes by namespaces in PHP, you need a Registry, and a way to parse the concrete files from a directory based on its namespace.


Whenever I’m working on a project that has an object-oriented code base and that uses Subscribers and Services, I often use a Registry. This makes it easy to

  • register the subscribers with the core application whenever the code runs,
  • de-couple any Service classes so they can be tested or even run isolation,
  • and maintain the code base whenever something has to be added or taken away.

One challenge with this approach though, at least in PHP, is that I’ve found myself having to go back into the Registry and set a reference to a given Subscriber whenever I want to add it (or remove it whenever I want to, you know, remove it).

Ideally, I want my registry to know where the subscribers are and how to set them up. This way, I can focus on working on the rest of the code.

Continue reading

Using PHP Sniffer & Beautifier for Visual Studio Code

TL;DR: There are a few PHP Code Sniffer extensions for Visual Studio Code. The one I prefer is PHP Sniffer & Beautifier by Samuel Hilson. Here’s where to get it and how to configure it.


Though this isn’t directly related to the material I’m writing about in my series on Ray on WordPress, it’s relevant enough to share at this point because:

  • the series is only going to include more code and i use this extension for writing said code,
  • over the last few months, I’ve found this extension to be really good in comparison to others that are available.

There are some other ones out that that are really good, and I’ve used them, but this is the one I’ve settled on using.

Continue reading
« Older posts

© 2022 Tom McFarlin

Theme by Anders NorenUp ↑