Introducing PDBlog

As I started resurrecting this site, I decided I wanted a blog. Sure, I could pick from among dozens of well-built blog apps, but I'd have to also run MySQL or something similar. However, I really want to treat the Lightsail instance that this site is hosted on as ephemeral/replaceable. I could opt to use RDS, but that is another cost that I don't need and not quite what I had in mind. I ended up deciding to build my own simple blog app using PHP and DynamoDB.

Building a full-featured blogging app is a daunting project. That wasn't my objective. I'm shooting for the minimum viable product. I need to be able to post and I need to show the posts. Simple stuff. I came up with the following milestones:

  • database initialization; post/edit via command-line; blog reading
  • UI improvements
  • RSS support
  • login and post/edit/preview via web
  • image upload/embedding

My first challenge was getting my dev environment running. I'm running Mac OS High Sierra, which includes Apache 2.4 and PHP 7.1. Amazon distributes DynamoDB Local, which is a dev version of their serverless NoSQL database and runs on my dev box. Surprisingly easy.

After a couple hours rereading and rewatching some tutorials on DynamoDB NoSQL data modeling, I had a solid plan for organizing my DynamoDB table. Now, to implement it...

Though I'm a novice with PHP and DynamoDB, they're fairly simple. For PHP there are a zillion resources online so any questions I had were easily answered. Helpfully, Amazon's documentation for the DynamoDB functions in the AWS SDK for PHP is pretty good.

After six or eight hours of work, I have accomplished first three milestones-- enough to go live. I've written:

  • PHP - script to initialize DynamoDB table and indexes
  • PHP - functions to add/edit/list/get blog posts
  • PHP - script to accept post info (command-line) and post to DynamoDB
  • HTML/PHP - index and permalink pages
  • XML/PHP - to generate RSS
  • CSS - a color scheme and style tweaks
  • one mod_rewrite rule in .htaccess

Under 500 lines of code and I have a minimally-functional solution in place. Not bad for a few evenings worth of tinkering.

Apr 14th, 2020