Tom McFarlin

Software, Development, and WordPress

Page 2 of 395

Writing PHP Command-Line Applications: Command-Line Arguments

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[0] is always the name that was used to run the script.
Continue reading

Writing PHP Command-Line Applications: A Basic 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):

  1. Know the path to the PHP binary,
  2. Make sure your script references said binary,
  3. And make the script executable.
Continue reading

An Introduction to DevKinsta

TL;DR: For how much this post may sound like a paid or promoted review, it’s not. The short of it is that I’ve been hosting this site on Kinsta for a few years now and I’ve been happy, and continually impressed at their offering so when they announced their DevKinsta application, I was just as interested to try it out as I have been with Local, Valet, MAMP, and others.


In short, DevKinsta bills itself as a way to:

Design, develop, and deploy WordPress sites from the comfort of your local machine. DevKinsta is free forever, and available for macOS and Windows.

Kinsta

But rather than walk through whatever videos and other collateral the site has to offer, I thought I’d go through the process of setting it up from download to site setup, from creating a site, to loading it in a browser, and taking a look at how everything is set up within the file structure.

Continue reading

I made a goal for myself in January 2020 to stop using Google products by the end of the year. That might sound like way too generous a timeline, but Google owned pretty much all of my data at that point, so it was a fairly large project. Plus I’m a slow and steady kind of person. I know if I give myself a generous enough timeline I can accomplish even things that seem too hard for me at first.

via Kira McLean

Merry Christmas and Happy Holidays (From 2020 to 2021)

If you’ve read my blog for at least a year, then you know that I usually take the time between Christmas and New Year’s to stay offline and visit with family and friends.

Obviously, this year is a little different for everyone but we’re fortunate enough to be surrounded with many who are near-and-dear.

Though I don’t do long retrospective posts, I do like to recap some of the things that have happened through the course of the year both offline and online.

Continue reading
« Older posts Newer posts »

© 2021 Tom McFarlin

Theme by Anders NorenUp ↑