Over the last few years, I’ve talked a lot about the nature of code quality and various tools, processes, and libraries that I recommend using when it comes to writing code for WordPress.

I’m also open that that majority of the work that I do is in backend development. This means that I work predominately on WordPress plugins using object-oriented programming and don’t work much with templates nor as much with front-end technologies.

It’s by choice, and I’m really happy with where I am. But I digress.

If you’re in the business of doing the same thing (or doing it as a hobby), it’s not just about writing the code. It’s about having proper tooling in place.

I’ve alluded to a few in these in previous posts, but I’ve not walked through the tools I use and the set up I use whenever I’m building a solution for myself or someone else.

At least not in an organized manner.

In this series, I’m going to do exactly that:

I’m going to cover the tools I use, the libraries I use, and how I use them.

Ultimately, the goal is that those of you who read this can incorporate them in your day-to-day work to write better code.

Better WordPress Code

Before we go any further, I’ll give a disclaimer first:

The previous series that I’ve done up to this point has been long. This series will not. I’m going to focus on shorter, more focused series and posts for a while.

With that I said, this series assumes you’re familiar with your IDE and have a cursory knowledge of Composer. For me, I use Visual Studio Code (and I’ve covered it quite a bit).

Better WordPress Code: Visual Studio Code

I’m going to be walking through the process from the very beginning up to the point of having a plugin ready to roll. No, this does not mean we’re writing a plugin. But we’re going to go right up to the edge.

So with that said, let’s get started.

Installing Composer

For those who have read this blog for a long time, then you know I’ve covered this before; however, I never want to assume anything like this when it comes to those who have recently joined or may be reading about this the first time.

If you’re already set up, then you may skip it; otherwise, let’s proceed.

What Does Global Installation Mean?

Installing an application globally means that it’s accessible everywhere on your system. That is, it doesn’t matter if you’re in your Documents directory or in a project directory, you can access the utility by the command-line.

And, sure, we can use Composer on a per-project basis (and I advocate for that), but there are times where it’s important to install Composer in a global setting, too.

And that’s what we’re going to do here.

Two Ways to Install Composer

Using Homebrew

If you use Homebrew, then it’s possible to install Composer using Homebrew. It’s arguably easier to install and upgrade.

Better WordPress Code: Homebrew

Of course, this assumes you have Homebrew installed. If you don’t and are interested, then enter this command:

Note, however, if you opt to go this route there’s going to be a few things you need to be familiar with around Homebrew. And though I’m a fan, it’s not really a part of this post. I’ve covered it in-depth in other posts (and you can always read the documentation).

Then you can install Composer, with Homebrew, by entering the following command:

Really isn’t, right?

Manually Installing Composer

The other way to install Composer is by downloading this file and then placing it in your global path.

Better WordPress Code: Composer

That is, once you download this file (note the link is an actual download so pay attention to where you place it!), you can then execute this command from within the terminal:

And this will move Composer to your global path.

Verify Composer’s Installation

Once you’ve followed one of the above steps, you should be able to test the version of Composer by running the following in your terminal:

And you should see something like this:

Better WordPress Code: Composer Version

If you don’t then double-check the steps above.

On to the Tools

One of the questions that occasionally come up, regarding Composer, is why? And though I could answer that in this post, remember that I’m working to keep these and this series a bit more succinct than the previous series.

So I’ll look to answer that, in brief, in the next post, as well as cover how to get started with a few tools after which we’ll begin seeing how it can play a larger role in developing WordPress plugins.