Adventures in PHP

I wanted to make a minor update to this site today and it turned out to be a bit of an ordeal. My objective was to add code syntax highlighting using highlight.js. Easy, right? Almost. Actually adding highlight.js was extremely easy.

But verifying that it was working was an ordeal. My dev environment is my Mac mini and I've upgraded to macOS 12.1 (Monterey) since the last time I worked on this site. Apple dropped support for PHP with macOS 12.1. But they didn't just drop support for PHP, they made it a pain to install because Apache modules need to be code-signed. The PHP modules installed via Homebrew are not code-signed, sadly. After I figured out that this was the issue (which took way too long), I went through the many-step process to set up a Certificate Authority, trust it, issue a code-signing certificate, and use that cert to sign Done, right?

Not so fast. During the "what the heck is broken?!" phase I uninstalled and reinstalled PHP, upgrading to PHP 8.1 and wiping out my config files in the process. Step one: downgrading to PHP 7.4 and redoing the signing. With my PHP configuration, however, it turns out that I have been running a non-standard config...

short_open_tag = On
error_reporting = E_ALL & ~E_NOTICE

I knew that short-open tags were non-standard, so that didn't surprise me. But I didn't realize that I was suppressing certain error messages, particularly those related to accessing undefined variables. Oops! Apparently accessing undefined variables is a bad idea. (I mean, yeah I know it is a bad idea. But I didn't realize that PHP would pump out errors for it unless you suppress them.)

On top of that, my hostname changed (which broke a bunch of things) and it took me a few minutes to remember how to start Docker so I could run local DynamoDB.

Add it all up and this minor change ate a large chunk of my evening. But look at that pretty syntax highlighting!

Jan 4th, 2022