Building a CakePHP web-application in 2 months, part time.

This article is also available in the following languages:
By tyler
This article outlines what I went through to produce the http://www.demolistic.com AJAX-driven website over the course of the last two months, working just nights and weekends.

Project Background

Demolistic is a list building community with integrated discussion boards for each list. A user can create a list topic (ie: Best Jazz Bands of the 1960s), and use the AJAX interface to add entries to the list. Other users, should they disagree with the list entries, can quickly spawn and edit their own version of the list. When this happens, Demolistic calculates a consensus based on all the lists, similar to a run-off election. Discussion boards are attached to each list topic, where users can debate the merits of anything put on the list.

I created Demolistic because I was sick of encountering "Top 10 X" or "5 things you should XYZ" lists that I totally disagreed with. The tools Demolistic provides allow users to better participate and engage authors.

Why CakePHP

If you have an idea for a web-application that has some interesting requirements, CakePHP provides an incredible springboard for making it happen. Full-fledged CMS systems such as Drupal drive me nuts for projects that require anything beyond a basic online-brochure style website. I've found that I end up spending more time fighting, trying to implement the feature within the framework, than it would take to write the CMS framework AND the feature. If you are a knowledgeable developer, CakePHP offers a better balance of flexibility and features.

That said, I am incredibly happy that I chose CakePHP for this project. I encountered very few issues with the library.

I've been asked why I went with 1.2 if it's still in RC. I've found 1.2 to be quite stable thus far. I encountered only two bugs through the course of the project.

Time Invested

When I was first looking at PHP frameworks to use, gauging implementation time in a given framework was important to me. I'd like to provide some insight to those of you exploring using CakePHP. I went from zero to site launch in two months, averaging 25 hours a week. Roughly 200 hours. I have a full-time job and said to myself that I would have no life until Demolistic was live. ;) It should be noted that this was my second major project in CakePHP. Please note that this was my second major project in CakePHP.

Scope and Feature Creep

Regardless of the project, you're going to encounter this. I was ruthless about trimming down the project until it was the perfect balance of needed features, and stuff for the roadmap. If you're ever feeling overwhelmed by what you want to create, I suggest a process of iteratively removing the least-needed feature from your list until the feeling is gone.

The approach I use when doing solo-development is a three stage process.

  1. Make it work well enough to judge if your vision of the feature actually works and alter plans if needed.
  2. Make it work flawlessly from the user's perspective. I don't care how good you code works under the hood, if it's not a good experience for the user, you've failed.
  3. If you have time, refactor your code so that it works as efficiently as possible.

I would like to note that the one thing I make no exceptions on in step 2 is with regards to security. Do yourself a favor if you're new to PHP - pick up Essential PHP Security and read the first couple chapters. Follow the conventions outlined in it and make good use of CakePHP's awesome Sanitize class.

Modifications to CakeLib

I did end up making one modification to the Cake Library. I wanted a simple way to turn off caching for authenticated users. I couldn't find a hook to check if the user was authenticated before the dispatcher delivered the cached version of a page. There may very well have been an alternative solution, but for the scope of the project and how quickly I wanted to launch Demolistic, it made sense to make a couple minor alterations.

SEO

I spend a lot of time ensuring that I followed best SEO practices to my knowledge. This included building out a flexible keyword generator and sluggable URLs. The lists themselves are obviously the most important content on the website, and the router connects them at the root of the domain.

Frontend

I went with XHTML Strict. I don't see much reason to go with anything less when you're targeting early adopters. You spend a lot less time getting things to render correctly and consistently when using XHTML strict. Internet Explorer 6 and 7 only gave me one headache through the whole course of converting the PSDs.

As with most CakePHP sites, I went with Scriptaculous and Prototype. The sortable list control that Scriptaculous provides was a core requirement for Demolistic. It allows you to quickly reorder your list as you're building it.

Backend

I actually started out with a much more complicated and proper DB schema when I built the prototype for Demolistic. My initial design focused data conformity rather than minimizing DB hits. It worked great from a user standpoint - the consensus version of the list immediately reflected your contributions. In the end, it made a lot more sense to move some of the code I built out into batch processing scripts, implemented in CakePHPs custom shell facility.

Administration

I built out a significant administration console. Any website with user-submitted content is going to have a jerk, or several hundred, on it eventually. I did some brainstorming on all the facilities needed for controlling that. One solution was to build out user-moderation facilities, like comment rating (and hiding poorly-rated comments.) But in the end, make sure you have all the facilities in place to take care up quickly cleaning up after someone should you need to. And make sure you implement before going live ;)

Development, Staging, and Deployment Environment

I use Eclipse with PDT for coding.


My local staging server is Ubuntu 7.10 Desktop. I use the desktop version because the staging server is my laptop. I tend to do a lot of work outside my home and don't always have an internet connection.

The live server is a vanilla CentOS 5x. quad-core Xeon server.


Conclusion

I hope the mish-mash of information provided in this article will provide some insight to working with CakePHP. I encourage all would-be entrepreneurs out there to put your head down and keep with it. Pour your heart into it. If you have any questions, I'll be happy to answer them in the comments. Cheers

[p]Demolistic can be viewed at http://www.demolistic.com

Comments

  • Posted 03/09/11 09:52:08 PM
    Congrats Tyler, really goog job!

    Would you consider sharing the code or sell licenses? it is actually very good job, everyone would like to learn from this.

    Congrats again!
  • Posted 01/15/09 07:56:35 AM
    Is there any way we can view the code? What this community really needs are some real-world working examples of things like adding items to a list from forms via ajax like you did, or admin routing, etc etc.

    I'm dying to look at your source for some of this.
  • Posted 01/04/09 08:04:02 AM
    Very nice work with you web-application!

    I'm also curious about your back-end...

    Do you have any tutorials on that?

    With Friendly Regards,
    NicoJuicy
  • Posted 01/02/09 05:25:09 PM
    I wish there were more inspiring articles like this one!

    This has really helped to give me perspective on the development processes and time frame of other a typical project.

    I am just about to embark on my first Cake project and you've given me some good food for thought.

    ...please feel free to write more articles like this one :)
  • Posted 12/29/08 11:19:22 PM
    Hey Tyler great site, I'm still new to Cake
    how about admin routing, ACL and other Built in component like Auth, Pagging, are you using it? or you create your own component?

    sory for my bad english..

    regard
    • Posted 01/01/09 03:32:13 AM
      Hey Tyler great site, I'm still new to Cake
      how about admin routing, ACL and other Built in component like Auth, Pagging, are you using it? or you create your own component?

      sory for my bad english..

      regard
      Hi Aditia,
      Yes, I do make use of admin routing - most of the actions have separate views for admins/moderators, allowing them to easily edit/delete lists, users, and comments. I basically built a "smart" toolbar that gets inserted into these views, and figures out what actions are available - for example, if viewing a user, the "ban user" command becomes available, or if viewing a list, the "delete list" command becomes available.

      I use Cake's built-in ACL facilities. I recommend following the tutorial in the book - it's written very well. I built out an ajax-driven view to manage permissions for all user-groups. It's quite rudimentary, but sufficient given the needs of this project.

      I also found the pagination helper in 1.2 to be quite sufficient for my needs and am using it.
  • Posted 12/29/08 08:05:20 PM
    You have seriously done a fabulous job at developing that website. It looks quite neat and it sure is a great concept.

Comments are closed for articles over a year old