More Web Development

As the CODVID-19 lockdown continues, I've continued doing more web development tinkering.

I've filled in some gaps in PDBlog's features. I can now login and add/edit/delete posts using via the web. No more posting via command line. I'm gonna work on image management and paging (or maybe infinite scrolling) next.

I'm still getting the hang of PHP. I'm finding a lot of similarities to ColdFusion, which was my jam for a decade starting around 1999. In fact, I haven't yet found anything "better" about PHP, compared to ColdFusion (from a decade ago), except that it is free and much more widely used. In many ways, ColdFusion then (much less now, which I haven't really looked into) was better than PHP is now. (To name a few ways: error handling, Application.cfm, shared variable scopes, CFCACHE.)

My next project is pulling my website off Squarespace and hosting it on my Lightsail box. I've been satisfied with Squarespace over the years-- it is just another fun project (plus it'll save me $80/year). I decided to do a slight redesign as part of that switchover. On this project I've learned more Bootstrap than PHP. I'm 90% done at this point-- I mostly just have to figure out when to switch everything over. My current setup is a bit convoluted: the domain is registered with Squarespace and my website is hosted there but I'm using Google for DNS resolution because I have Google Apps for that domain.. I'll figure something out.

Apr 14th, 2020

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.