TL;DR: I’ve been writing PHP command-line scripts to help automate mundane tasks. As these tasks are growing in complexity or turning more into applications that interface with third-party APIs, I’m documenting the things I find important that others may also find helpful.
There are three things necessary to get a basic script up and running on your local machine (assuming you already have PHP installed):
macOS is still shipping with PHP (though how this looks for future versions of the OS is likely going to change in some way.).
Anyway, imagine you’re in a situation where you’re working on a project that requires three different components:
A set of coding standards,
PHP CodeSniffer that work with said coding standards,
The inability to properly see results of sniffing the code either in your terminal or your IDE.
When this happens, this is almost always a result of a version of PHP, the version of the various dependencies, and making sure they all play well together.
In short, it’s about making sure the tools like PHP CodeSniffer work well with the same version of PHP you have installed. And in this case, the latest and greatest isn’t necessarily the best course of action.
It is, however, close. And in the following steps, you should be able to get everything working exactly as needed for your specific set up.
There are a lot of nice packages that we can use in our PHP-based projects and if you’re using Composer or GrumPHP, PHPCompatibility is one that I recommend including your projects especially if you’re writing code for something that’s going to run across multiple versions of PHP (that is, on hosts that offer different versions).
This is a set of sniffs for PHP CodeSniffer that checks for PHP cross-version compatibility. It will allow you to analyse your code for compatibility with higher and lower versions of PHP.
Over the past few years, I’ve spent a significant amount of time writing about a lot of things on how to achieve certain things in WordPress. And I don’t regret it (after all, it’s my career and it’s even the subtitle and focus of this blog).
But one of the things that I’ve opted to neglect is a focus more on topics that interest me such as object-oriented analysis, programming, design, and implementation. (And, of course, doing so within the context of WordPress.)
And sure, there are some articles where I’ve touched on it but I recently took a week off of pretty much everything except my [growing] family and during that time, I took stock of a variety of things.
One of those things included this particular site, its content, and the general focus of my career.
If you are looking for WordPress guides and unbiased reviews, I recommend checking out WPKube. They also have an exclusive deals section.
Just Getting Started with WordPress? I write a lot about WordPress development but if you're just getting started, I recommend checking out WPBeginner. They have free training videos, glossary, and more.