How to Build a Content Management System

OK, I just tricked you! This article is not going to teach you how to build a content management system with PHP from scratch.

Why not?

… Because building a content management system from scratch is (probably) a really dumb idea!! Now that I come to think about it, building any of the most commonly used software from scratch, is kinda stupid.

Things you should not build from scratch:

  • Content Management Systems
  • Blog Software
  • Forums
  • Directory scripts

The Top 3 Rules in Programming

The real estate business has a famous set of rules – the top three rules in fact:

  1. Location
  2. Location
  3. Location

The idea behind this rule, is to stress how important location is to a piece of property. In software development (programming), we have a similar set of key rules:

  1. Reuse
  2. Reuse
  3. Reuse

Yes, if you are a smart and experienced programmer, you know that the first thing you do when someone approaches you with a project, is to fire up Google to check if someone else has already built something that is at least similar to what you want to create.

… Simply stated, it is crazy to reinvent the wheel and build something that has already been created. Especially within the context of building a program to help support some business. What I mean by that is, that unless you are building a piece of software as the core of a business, where the software itself is the business, then you should not be starting from scratch. It’s just too expensive.

Lucky for us PHP nerds, there is a huge collection of open source, free and nearly free software out there created in PHP. Things like the above mentioned blogs, cms’, forums etc … have been created many times over by teams of adventurous nerds. Given that fact, it makes even less sense to build these things yourself, just because you need one for your website.

Don’t ask me how to build a CMS!
No, instead of trying to build these (typically) big and complicated programs from scratch, you should download a proven mature product where they have already worked out many of the bugs and spent the hundreds of hours refining them.

Suggestions:

A good blog software: http://wordpress.org/

Forums:

http://www.phpbb.com/
http://fluxbb.org/
http://punbb.informer.com/
http://www.vbulletin.com/
http://www.invisionpower.com/community/board/features.html

CMS

http://drupal.org/
http://expressionengine.com/
http://www.cmsmadesimple.org/

Believe me, there are many more out there.

Thanks for reading,

Stefan Mischook

www.killerphp.com
www.killersites.com


This entry was posted on Sunday, October 5th, 2008 at 8:47 pm and is filed under Beginners PHP Articles, Editorial. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

33 Responses to “How to Build a Content Management System”

  1. RST says:

    There are at least two reasons why building a CMS from scratch is the opposite of dumb. ;-)

    1. A client really needs a tailored CMS and existing scripts won’t do.

    2. If I have a software company with skilled programmers, why would I use an existing CMS when I can create a good one myself and sell it to other people.

  2. lacisoft says:

    I do not agree with you. People should try to build something. Because that is how many CMSes (Drupal, Joomla, Typo3 and so on) have been made. Someone had a vision and wanted something. He put energy into it and built something. Sure there are cases where building a CMS is just pointless for the task in hand. But i saw many projects where existing solutions proved to be very inflexible and caused much more trouble then it was the case.

  3. Stefan Mischook says:

    RST,

    To answer your questions:

    “A client really needs a tailored CMS and existing scripts won’t do.”

    Well, all you need to do is modify and existing CMS. If the CMS is reasonably well designed, you should be able to modify it to suit your needs in most cases.

    If on the other hand, you want to get into the business of selling a CMS, then building from scratch can make sense.

    Stefan

  4. David Dashifen Kees says:

    I’m torn on this one. I think it’s important for people to try their hand at forums, blogs, etc. because they’re somewhat foundational to the modern web and, by trying to build them yourself, you’ll better understand the methodologies of that web. Further, since the functionality of such tools is often well-defined, they make wonderful educational tools for someone to use to enhance their programming skills.

    Secondly, I usually find that my customers specifically tell me that they don’t want to use commercial or free third-party tools because they don’t want people to be able to recognize that they’re using other people’s work. They want their own site, with their own look/feel, made from their own code, that works just for them. That sort of specificity cannot often be found simply by modifying an existing site.

    On the other hand, if you’re client or boss is open to third-party tools then I’m a strong advocate of using them if only to save time for those projects and programs that must be performed in-house.

  5. Stefan Mischook says:

    lacisoft,

    Projects like Drupal, Typo3 etc … have had hundreds (if not thousands) of hours invested in them. It is not likely you will be able to create a CMS that is nearly as functional or robust. It makes more sense to find a well designed (object oriented) CMS (Expression Engine perhaps?) and modify that.

    As with all my opinions, this one is based on real-life experience, not some theoretical thinking.

    Stefan

  6. Stefan Mischook says:

    David,

    I would argue you would learn a lot more quickly by weaving into an existing project adding new functionality/modules. It is in fact extremely educational to dig into other peoples work to see how they did things.

    For instance, WordPress has a good plug-in architecture making it easy to alter the way WordPress works.

  7. freddy says:

    nah dude, if you’re a beginner, building a CMS, Blogs and Forums are the way to go so you can learn your shizznit! Then, after you know how to code, using an existent script is way faster then re-inventing the wheel every time. Good stuff. – freddy

  8. Maria Irrera says:

    Stefan,
    You are saving my sanity with your wonderful tutorials. I can not tell you the money I have spent on “beginner” books that assume I know programming when what i know is clever cut and paste.

    I have worked my way down to your PHP forms tutorial and I am embarrassed to say I have never had to build an HTML form from scratch. You mentioned that you had a refresher tutorial on HTML forms on this site and I have searched fruitlessly. I know I would eventually find it because I am addicted to procrastination and the hunt, but I see that you post regularly, so I thought maybe some other newbie might want the same info.

    Again, your videos are superb! I can’t believe you even pointed the way to me actually running the server on my computer. Many failed attempts to do this the hard way, all the time going “Why do i need to do this when I have a hosting provider?”. You addressed it beautifully, and I have installed Xampp.

  9. Stefan Mischook says:

    Hi,

    My forms video is contained in my basic web design package. You can find it here but it has a small cost: $19.99.

    http://www.killersites.com/web-design

    Hope that helps.

    Stefan

  10. Maria Irrera says:

    Thanks Stefan,
    I figured it out using Google, but I am going to purchase your beginner videos anyway. I realize starting out as a graphic designer myself, with no tech experience, I have advanced through cleverness, but no real foundation. I think going through your videos will fill in some gaps, even in HTML. I hope you keep posting tutorials!

  11. Stefan Mischook says:

    Hi Maria,

    I will continue for sure. You can actually expect a few new ones soon.

    Stefan

  12. Christain South says:

    Stefan,
    I guess I can see this one from both sides of the argument. The time you spend “reinventing the wheel” could almost certainly be put toward more productive learning experiences else where. With that said… I probably don’t have anywhere near the knowledge that most other people in the above comments have. As such I have a fairly different prospective then the above people (the newbie). I find that I learn a tab bit more not by just using the application that I can get “off the shelf” from a download, but by started to build my own and researching how the others go about doing x when I get stuck. No doubt when I have the years in that you and the above have I may change the way I look at it, but currently this is the way I look at it. I think you could actually learn more from the building experience then just reading through someone else’s code that is almost always poorly documented, broken up, and just plain ugly.

    I sit back and await my flame :)

    Christian

  13. WebGyver says:

    Good article, Stefan! Thank you.

    You can always tell you’re on to something when you hit a nerve and people start participating in the discussions.

    Personally, I couldn’t agree with you more: Why reinvent the wheel (unless you need one that’s not round and doesn’t roll very well)? Then again, I have a boss who couldn’t be convinced that outsourcing $50K for another MySpace clone was a terrible idea.

    QUICK QUESTION: What do you mean by “Directory Scripts” and what is out there that can be re-used?

  14. Stefan Mischook says:

    WebGyver,

    When I mentioned directory scripts, I am talking about directories like our web designers directory:

    http://www.killersites.com/directory/

    You said:

    “I have a boss who couldn’t be convinced that outsourcing $50K for another MySpace clone was a terrible idea.”

    Yea. Been there, done that!

    I would venture a guess, that the people who think building a CMS from scratch is a good idea, are probably those who haven’t much experience in the real world.

    Like my old boxing coach used to say: “You don’t really understand why you should put your hands up … until you get your nose broken a couple of times.”

    … Fortunately for me, rhinoplasty is reasonably cheap these days!

    Stefan

  15. Willem says:

    I agree on using a open-source CMS, but i also have the impression going through the documentation of these CMS’s that there are certain limitations imposed by them. Now, I don’t have much experience using Drupal or Joomla or CMSMS, so I hope someone proves me wrong.
    But can you build a website for a client with their own admin system (next to your bigger admin system which includes the Drupal setup) and then setup the views just like you want (multi-image gallery) with a Javascript framework, built into the views and the client’s admin system.

    Then to me it seems easier to do it the ‘old’ way. Although i’d love to be proven wrong.

  16. Stefan Mischook says:

    “But can you build a website for a client with their own admin system (next to your bigger admin system which includes the Drupal setup) and then setup the views just like you want (multi-image gallery) with a Javascript framework, built into the views and the client’s admin system.”

    Depends on the CMS and how well (modular) it is built. A good OOP based CMS should allow you to hook into it and add new functionality.

    That said, I would still hold that in most circumstances, it would be better to base your work on a mature open source CMS than to start from scratch.

    … Just think about all the things they’ve already have in place!

    Stefan

  17. Ashley says:

    On a professional level, you should be selling your own code. Taking an existing CMS and tweaking it to meet a clients needs may be quicker and cheaper, but cutting corners is not the key to successful business. Sure you’ll be making something that has been done similarly somewhere else before, but think about it, doing bespoke jobs with tweaked, existing applications does not make sense!

    Most clients are paying to get their own things made, not for developers to take free/open-source applications, change them (which, let’s face it, you don’t need to know much to do), and sell them for high prices. To anyone who does this practise at work, I bet most of the time you will not make it clear to your clients that you’re even doing this. I totally understand re-using code, it is a necessity, but that is more about re-using your own code, not someone else’s.

    It’s worth creating a CMS structure yourself, and working with that code on each client project. Yes it may take a while if it’s going to be a particularly big system, but suck it up, that’s the work life for you. You should know your own code. You’ll have integrity, you’ll be selling YOUR work and not ripping off clients. This is something you can take pride in, and the fact it’ll all be your own work is a great way to sell yourself.

    To those that are going to go down the road that this article is supporting, be very careful around the laws of selling free and open-source applications (even if very heavily modified, usually the least you need is some kind of license/agreement where you will need to pay the original creator(s). And make sure your services are advertised with the upmost honesty. “It’s only illegal if you’re caught” is so not true. I wish all the best to you aspiring web designers/developers out there!

  18. sideright says:

    Building you own CMS can be very beneficial to the team because of customization. Anyone looking to build their own CMS should just google CMS tutorial there are plenty of good ones out there. I suppose you’ve never built your own CMS?

  19. Stefan Mischook says:

    I’ve built them 7+ years ago because at the time, I had to.

  20. Gary says:

    Stefan
    If I simply want to build a ‘simple’ web site — where my friends can review / share their ideas about the restaurants in the city I live in… and then have a message board like what you have here….
    Am I better off using an existing cms… and modify it
    Or is it easier that I write my own?
    I am not in to the “fancy” feel and looks… just want something robust.

  21. Stefan Mischook says:

    “Am I better off using an existing cms… and modify it”

    It is by far the better choice to use an existing CMS and modify. By far!

    Stefan

  22. Chuck Middaugh says:

    Reading through these replies, I get the feeling that a few people have never read the GNU/GPL agreement. GNU/GPL software has one primary intention and that is to progress human knowledge to the ever changing next level. If you spend your time “reinventing the wheel” what have you gained? So, now you have yet another wheel, good for you. There is no reason that you cannot develop new extensions, modules ans plugins to your favorite GNU/GPL CMS and sell that packaged with the custom template. It is your legal right and it is in the spirit of GNU/GPL to do so. If you improve on existing portions of the GNU/GPL code, then share it that is all that is expected of you.

    I have been developing websites for many years oblivious to my need to learn anything new. I wrote clean XHTML 1.0, CSS 2, and Javascript code. My websites were beautiful and highly functional. I thought to myself that I was doing well enough, until I was asked to build a forum with calanders and various other accoutrements, and they wanted it in one day.

    “What”, I thought. I cannot do that. I understand what that would take and even how to go about it, but the deadline was not possible for just me to accomplish. It was just physically impossible. I should mention here that at the time I had never even heard of CMS. Needless to say I was “let go”. As I continued working on building said website to satisfy myself that if I was ever faced with the same situation I would already have all of the elements within my possession, I began learning PHP (from this website) and googled every known term I could think of to search for and learn.

    Fortunately, an old friend wrote to me and happened to mention Joomla, so I looked it up and not really understanding what CMS was all about I installed it on my localhost. Sceptically I began combing through it and found, to my amazement that it was what I was trying to do. I have learned to do so much by seeing how it has been done.

    Stefan, I must agree with you. I got my nose broken and now my hands are up. Learning from experience is painful, and learning to listen to good advice is the path of wisdom. Stefan, Thank you.

  23. Stefan Mischook says:

    Hi Chuck,

    I’m happy to hear I was able to help.

    I too have been in your situation and unfortunately, for many of us, it takes a broken nose (or two) before you learn!!

    … I got the crooked nose to show for it too!

    Stefan

  24. lebisol says:

    @Stefan
    …and how many hours did Drupal have invested at dev. day #1?How many people worked on it?

    Just because tools/products exist it doesn’t mean that are good in quality even if you pay for them, hence the idea of competition.
    Often, the effort to customize someone else’s code and figure out what the author was thinking will take longer than writing your own based on well established programming standards.
    And don’t be surprised if you hit the ‘not possible without major redesign’ wall.Look at the WordPress…a great blogging tool but people wanted to bend it into CMS and look where it sits today. Plugins galore and admin nightmare….if your plugins ever get updated. Less is better ;)

    On the other hand, it is true..if you just need a simple blogging platform or forum app then it is a no brainier. Wheel has been invented long time ago, just learn how to drive :)

    The most important part is to:
    1. have clearly defined goals of what you want to accomplish(build)
    2. be aware of your (in)abilities
    3. be prepared to accept limitations of existing product (and NOT cry to creators about it)

    Clever use of title you little sneaky… :D

  25. Stefan Mischook says:

    “Clever use of title you little sneaky… :D

    I do my best!

    Stefan

  26. Noncasus says:

    “Often, the effort to customize someone else’s code and figure out what the author was thinking will take longer than writing your own based on well established programming standards.”

    I believe what lebisol said is 100% true. I’ve had my fair share of having to customize certain CMS’s ranging from video CMSs to news article CMS’s all the way to shopping cart CMS’s and it is a nightmare.

    I would rather just make one of each myself instead of delving into the code of a genius-level programmer.

    Now granted I don’t have much real world experience (aside from what I stated above) but during my studies I was able to tell, and heck even in the small amount of time I was pitching in at a company, that it is highly unlikely for two programmers to create a piece of software where they use the same methods. In other words, there is more than one way to skin a cat.

    Each programmer has his own way of programming and if the genius-level programmer has his method of coding then you are going to be stuck deciphering, troubleshooting, debugging, etc. until you understand you either understand his code or become frustrated enough to call it quits (which in turn makes you look bad).

    One other good thing about creating your own CMS (whichever kind that may be) is to try and think of HOW you would go about making it. I for one learned a whole bunch by thinking on how to get to the solution for the most common problems, for example:

    – If I want a logging system, what would I need? (cookies, session data in a table, hashes/salts, etc).
    – If I want to publish news articles how would I go about doing it, or which text editor would I use? (wysiwyg and whatnot)
    – If I want to upload photos? Use an open source script like swfupload of make a not so complicated script using PHP.

    In essence I learned PHP, MySQL, and some Javascript.

    My 2 cents :D

    P.S.

    Excellent site btw Stefan. Looking to get into OOP PHP but it is just so difficult for me to understand it since I am a hardcore procedural programmer… ugh.

  27. Stefan Mischook says:

    “Excellent site btw Stefan. Looking to get into OOP PHP but it is just so difficult for me to understand it since I am a hardcore procedural programmer… ugh.”

    Thanks for the kind words. Try out my OOP tutorial, people tell me it is the easiest one on the Web:

    http://www.killerphp.com/tutorials/object-oriented-php/

    Stefan

  28. tkane2000 says:

    Good post and some valid points on both sides. For a side project, I built a site and ran into this exact issue. The site has some basic pages like Contact, People, etc and then some pages w/ lists of playlists of videos. It also has an authenticated client section in which the site admins can use blog software to create custom content for specific users (not the other way around).

    So, my first thought was to use WordPress for the whole site since it already took care of the blogging portion. However, there was no easy way to create the video lists and add to a page. The plugins I found at the time were much too specific. At that point, I started looking into creating my own plugins, but I found that it would be the same amount of work and then some to learn the WordPress API. Also, as simple as it sounds, what I wanted to do didn’t seem to really fit into the WP architecture.

    My final solution was to combine the 2. I build a CMS that manages clients and lists of playlists of videos. The blog functionality is all handled by WordPress…you just drop the post id into the client page of my custom CMS to associate them.

    The CMS is very bare bones and was more work than I anticipated. I cut some corners to get it finished as quickly as possible and so I’m not extremely proud of the code…at least some of it. It was definitely a good learning experience though since I ended up using MySql, PEAR modules, etc, etc plus WordPress.

    It’s always been my feeling that I should move it ove to a pre-built OS CMS since it would be so much more robust, but every time I start to look into it I’m put off by how over encompassing they are. By that I mean, they just try to do too much to make things easy for you that it limits the flexibility of their use. One thing I’d love to do is to rewrite my CMS and put it out there for those who are put off in the same way as I am about the pre-existing options.

    Final thoughts:
    – Re-use is always the best way to go if it fits. I definitely disagree that pride is a good reason to write you’re own code. This is business, if you can do things faster than you should! Also, much of programming is based around the concept of re-use, so if you’re missing that you’re really missing fundmentals.
    – When it’s not a good fit can be a very bad move so do your research before you make your choice. I’ve heard some horror stories on that side as well!

  29. Stefan Mischook says:

    “When it’s not a good fit can be a very bad move so do your research before you make your choice. I’ve heard some horror stories on that side as well!”

    That’s why knowing a good CMS is a good move. It will make you life a lot easier as you will be able to leverage it more easily or more easily decide to not use it … given the project at hand.

    Stefan

  30. Akaninyene Bassey says:

    I think for commercial purposes it is best to use a CMS software considering the fact that this software were well developed, for the purpose of learning there are great resources to teach you that but you might not really be able to design a good and effective one

  31. qwerty says:

    building a CMS, or BLOG or FORUM or anything is a good idea because you learn! is difficult to understand to a top programers like you? do you forget to learn?

  32. Stefan Mischook says:

    @ qwerty,

    Not at all. All I am saying is that building things that are already out there makes no sense. Sure, you will learn by building a blog or forum from scratch. But why not build an Android app that has never been done before?

    … Besides teaching PHP programming, I also try to teach basic business sense as well!

    :)

    Stefan

  33. Nerthern Erverns says:

    I am looking for a template that allows a site admin to login to a webpage and manage an image gallery. The images would be displayed on the front end of the using html/css. does anyone know a good place to start?

Created By Stefan Mischook  |  Top of page  go to top of page