Flat file PHP CMS or Blog, simple and customizable
Sep 3, 2009 Complete Scripts
In this and the next few posts, we’ll see how to create a simple flat file blog or CMS in PHP.
I mean a really simple one, useful when you have just a few pages to manage, and installing Wordpress would be an overkill.
Why flat file?
Because you may need to populate many sites with content, using a cheap hosting service where mySql is not available, or has a limit on the number of simultaneous connections.
For a small number of articles, such as a Mini Site with 30/50 articles of 500 words each, the resulting file would be less than 50Kb and allow for immediate deployment of the site wherever you want.
To keep things simple and hacker proof, we’ll not include an admin backend. Adding articles will be done offline in a text editor.
Let’s start outlining the requirements for our blog/cms. It should be able to:
1. Handle SEO friendly urls
This means urls will look like mysite.com/this-is-a-post.html instead of the ugly mysite.com/index.php?m=73.
2. Have SEO friendly page titles
As well as per-page meta tags and meta descriptions.
3. Be able to be used as a Blog or as a CMS
Here we’ll draw a line and state that author and post date are optional items. When present, the page will be considered a blog post. Otherwise a “static” page.
4. Be able to make use of custom or Artisteer templates
If you don’t know Artisteer, it’s a remarkable piece of software, available both for Mac and Windows. It creates great looking cross browser templates for Wordpress, Joomla, Drupal and static sites.
Hacking the xhtml template Artisteer provides, we’ll be able to quickly change the look of our Minisite.Of course we can also code the page by hand or using another web design tool.
5. Graceful error handling
Providing a meaningful 404 error code if the url is not in the database is a must.
6. Expandable
Again, the goal is to keep code as short and simple as possible, but with a little pre-planning we can make sure the script is scalable and can easily be expanded to handle more complex tasks.
Interested? then head on to the next post where we’ll start building it.
Tags: flat file blog, flatfile cms, seo urls, simple php cms


September 3rd, 2009 at 10:27 am
Looking forward to the blogposts, I’m writing a CMS called 3PageBlog at the moment. With only 3 php pages but some of the key features (like mod_rewrite) I do not get working.
September 3rd, 2009 at 11:02 am
Url rewriting in this simple cms is… simple! I just fetch the url the user requested then use it to find the article, and display it. If the url is not found it issues a 404.
Will post parts 2 & 3 the next few days, hope they’ll be useful for your project.
September 30th, 2009 at 11:02 am
Thats very good to know… thanks