A few months ago, I had the pleasure of writing the forward to Cal Evans book Using the WordPress REST API. Shortly thereafter, Cal asked if I’d join him on his podcast, Voices of the elePHPant, to talk a bit about software development in the context of WordPress.
And given that that’s what I’ve spent the majority of my career doing, it made sense to participate.
This not only gave me a chance to catch up with Cal “face-to-face” but also to share a bit about what it’s like working in this particular corner of the PHP community and in the WordPress economy.
It’s one thing to be using PHP CodeSniffer manually but if you’re using a utility such as GrumPHP to check your work before committing it to the repository, then you’re likely going to want to use the version that you’re installing with your project.
This assumes that:
You are installing PHP CodeSniffer local to your project,
You want to install a specific set of coding standards to run against your code.
Remember, this is also done in the context of wanting to run automated scripts during the commit process and in a local environment (versus a global setting) with Composer.
cURL is a very popular PHP library that I’ve referenced in several posts other posts (1 and 2, for example). And it’s one that I think should be reviewed, explored, and possibly used by anyone working in PHP (yes, even those working in WordPress).
But because of the native WordPress APIs, we do have a level of abstraction that allows us to achieve much of the same functionality (if not the same functionality).
This function is ideal when the HTTP request is being made to an arbitrary URL. The URL is validated to avoid redirection and request forgery attacks.
I specifically mention the safe variant of this function for the definition above (there is another variant, but it’s important to take precautions against arbitrary URLs for security reasons). Continue reading
If you happen to see two different versions of PHP whenever you run:
php -v in the console and visit
phpinfo() in the browser
Then this usually means the version of PHP that your web server is using is different than the version of PHP your command-line is using.
Specifically, this means you likely have more than one installation, and the web server is using one version, and the terminal is using a different version (in addition to using a CLI version of the interpreter).
Of course, if you’re seeing the browser and the terminal show different versions of PHP then something is wrong. You want them to be the same, but depending on how your system is configured, then you may need to update your environmental variables.
I was recently having issues with this with various installations of PHP installed via Homebrew and with my local installation of Valet.
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.