Simple Flat File PHP CMS or Blog

Are you looking for a simple flatfile CMS that can be used to deploy thousands of small sites with little to no server load? Follow this series, and we’ll see how to build such a system, expanding it as the need arise.

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 if you do web design you may need to populate many sites with your clients content, often 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 pages, such as a Mini Site with 30/50 pages with product description, articles of 500 words each, and the usual About / Contact / Privacy pages, 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.

If you have ever experienced what does it mean to manage 60 or more client’s sites on dynamic platforms such as WordPress or Joomla, then you’ll appreciate this approach even more.

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. This will cover 99% of commercial “shop window” mini sites.
  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.

Posted in Complete Scripts
3 comments on “Simple Flat File PHP CMS or Blog
  1. Joris says:

    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.

  2. PhpTips says:

    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.

  3. Kelli Garner says:

    Thats very good to know… thanks

Leave a Reply

Your email address will not be published. Required fields are marked *

*