2017 update: This is a really old post. This blog no longer uses the PHP code described, and I no longer think that PHP is appropriate for web development, especially plain PHP templates because they do not auto-escape by default.
I've managed to complete my new blogging software, and I'm rather pleased with myself about it too.
The web pages may look fairly similar, but under the hood it's completely brand new. One new feature is a much better categories system - have a look at the side bar - and a proper template engine, which is reflected in the fact that the title of the page changes on the pages for individual items, amongst other things. Also, for those of you using the RSS feed, have a look at my feeds page where you can customise your feed to posts that are of interest to you. The comment forms now also have a 'Preview' button.
The lack of filtering by category was one thing that was holding me back a bit - I'm aware that posting about software and computers half the time is going to make this fairly boring to most of the Christians who might read this blog. But now you can filter that out yourself!
I was pleased with how quickly I was able to develop this lot, and with the quality of the resulting code – it took me about 5 evenings, and then about half of today to add basic admin functions.
My method is based around the excellent PHP Template Engine I mentioned before. Did I mentioned that it is the best PHP Template Engine there is? It's really great (that's for Google). In total I've got around 1600 lines of code, but that includes the template engine (which is only about 40 lines), admin functions for adding, listing, deleting and editing posts, a very simple but powerful flatfile database class I had to write at the same time, functions for getting cached remote files (used for my blogrolls), the RSS feed, the RSS feed picker, and a trackback server (pinched mainly from WordPress), as well as the front end stuff. I've also implemented a kind of MVC (Model View Controller) system, and I have a complete data access layer (though one which is as simple as it can be - due to PHP data structures my data model is reduced to a list of constants). I've loved how flexible the template engine stuff is too - you can use it for as much or as little of any page as you want.
Lots of things came together to make this project first very quick, and secondly something I'm proud of (can you tell?!): First was the template engine, and realising that the goal is separation of presentation and 'business' logic, NOT separation of PHP and HTML (or separation of declarative and imperative code, to put it more generically); Second, keeping in mind lots of the criticisms of OOP I've been reading, especially Object Oriented Programming Oversold and related articles; third, and ironically, being more aware of MVC and other design patterns; fourth, having a better grasp of how to design databases. The resulting code tries to use a variety of paradigms as and when they are useful. It also uses some techniques and ideas I've not seen before, which at first seemed like a bit of a hack, but after reading some more of the stuff about Table Oriented Programming I've now decided are a deliberate move!
The code still isn't perfect (or complete - I haven't don't bulk moderation of comments yet, or admin front end for adding categories), and it hasn't totally eliminated in all areas the tedious mapping of database fields to user interface fields, which was something I was aiming for. There are also things I'm still working out and experimenting with, but I've got a pretty good basis for further PHP apps.
One nice thing I've implemented is separation of the presentation and control of forms such as the comments form. This will enable me to make it fairly spam proof in the future, which is fast becoming a priority.
I'll be writing up separate entries on the range of things I've learnt with this project - it has been frustrating not having the software complete enough to use it for blogging for this past week!