TL;DR: $argv is an array of arguments passed to the script with the first index being the name of the script itself. And $argc is the number of arguments passed to the the script (which will always at least be 1).
Arguably, pun intended, one of the key pieces of command-line application is making sure that they are interactive through command-line arguments. In PHP, there are two variables to understand:
$argc is the number of arguments passed to script. Note the script’s filename is always passed as an argument to the script, therefore the minimum value of $argc is 1.
$argv is an array of arguments passed to script. Note the first argument $argv is always the name that was used to run the script.
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):
TL;DR: In this quick tip, I provide a simple query for determine the size of a database (that includes all tables). This is useful when determine what the largest tables are, especially if there are custom tables in your WordPress installation, and how large they actually are.
TL;DR: If the standard terminal commands don’t work for uninstalling and reinstalling the Xcode CLI tools, use this page and search for the latest version of the tools to download. You don’t need a developer account to access it.
If you work both in a terminal and on a Mac, then you’re likely familiar with the Xcode Command Line Tools (and the necessary utilities they provide for things like Git, building front-end assets, etc.).
If you’re not familiar, here’s the gist:
[Command Line Tools] enables UNIX-style development via Terminal by installing command line developer tools, as well ass macOS SDK frameworks and headers. Many useful tools are included such as the Apple eLLVM compiler, linker, and Make.
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.