A PHP Developer's Blog - Joakim Nygård

About jokke.dk

jokke.dk is the personal website of , a software architect, entrepeneur and Mac user living in Copenhagen, Denmark. Read more »

Search the Site

Reimplementing the site

30th September, 2006

What should've been an easy move to my new hosting provider Dreamhost turned out to be quite time consuming. The thing is, I wanted to upgrade the backend and freshen up the design while I was at it.

Looking for a framework

I've been looking for a decent framework to base future webapps on for some time now and thought I'd use this site as a test case, once I found one. I was looking for a modern, lightweight framework implementing the MVC pattern, preferably PHP5 based and with easy-to-use validation and security features. It should come with good documentation and be actively developed. I've played around with CakePHP, Symfony, Zend Framework and read about lots of others. They are either not yet complete enough or too cumbersome to use for my taste and needs. Symfony is very feature complete but it does feels a little heavy for smaller projects and the learning curve is, despite their very good documentation, quite steep.

Then I stumbled upon Code Igniter in my daily dosage of work related websites and feeds, and it immediately caught my attention. Browsing through their user guide quickly convinced me to install it for a test drive. Within hours I had this blog implemented. Code Igniter is fast, well written (although, since it supports PHP4, some of the code isn't as clean as it could be) and very much in line with my own thoughts on small frameworks.

I had a list of new features for my reimplemented blog, including three things I'd wanted to do for a long time:

  • Clean URLs as in "/2006/09/reimplementing_the_site" rather than "/?id=399"
  • Better entry markup using John Gruber's Markdown syntax
  • Commment spam blocking, inspired by Allan Odgaard's clever ideas

With mod_rewrite taking care of the clean urls and handling old style requests, Markdown needing just slightly modification for Code Igniter and a little JavaScript/PHP magic to keep out the spambots, the easy part was done.

I had hoped the Blogging bundle by Brad Choate for TextMate would be easy to implement, but I've only managed to get it to fetch the list of recent entries so far.

Show me the menu

Every time I redesign this site, I think about the navigation in terms of how to programatically build a reasonable menu structure. The problem (which I'm blowing out of proportion here, considering the size of this site) is that of automation versus flexibility. I don't like to hardcode the links in the HTML, but coming up with a data structure for the menu hasn't worked for me yet. Since only the blog is in a database (the rest is more or less flat files) I need a flexible structure capable of representing both. Here's a simple example in XML

<?xml version="1.0" encoding="utf-8"?>
            <name>First sub</name>

I still need the logic to figure out the active page and, particularly, a consistent way of linking around from outside the menu, e.g. from the blog.

So far

I ended up modifying the hardcoded menu of the old site, not least because I already spent too much time cleaning up non-blog code and making sure my mod_rewrite was working.

Everything outside the blog is only slightly modified to work with Code Igniter and hasn't yet been re-coded. Since it's (mostly) static content with some data used elsewhere (like the latest version of my software in the sidebar), it's a balance between using flat text files and parsing it through PHP to do some manipulation.

I'll be thinking about the menu data structure and slowly get everything re-coded in Code Igniter over the next couple of weeks.

« Three weeks  –  Email problems »