2 Notes

KLCK & ChairBro - The tech stack

I was just asked on Twitter how I built KLCK, so here is a pretty good break down of the technology and the order things were done.

For quite some time I have testing and working on different systems and frameworks.  I love Python but didn’t really want to host this app on app Engine and I have been doing a lot of PHP work lately. I have done a site in Ruby on Rails but find it quite complicated to come back to you if you dont do Rails fulltime, I had such a horrible experience hosting Ruby that its really put me off Ruby & Rails, but I love Ruby as language (yes I know about Sinatra).  So this was the technology of choice, probably because it is easy to host and configure and pretty solid at the end of the day (even if it is a bit ugly at times).

So to start off with I built www.ChairBro.co.nz which is powered by 1 file, index.php.

This uses a super simple framework called Silex http://silex.sensiolabs.org/
Silex allows you to run your whole website from 1 file and manages all your routes etc. Its simple and flexible.

To make things super simple, the HTML uses Smarty Templates http://smarty.net/ which allows you to inherit and extend your HTML files.  In essence you can create a master template file and inherit this into other templates.  Choosing smarty was the best choice I made here. One thing about smarty is that it will compile your templates+code on the first run.  So you templates are not parsed on every request, they are parsed once and then turned into pure PHP code. So KLCK, ChairBro run render super fast on the server. 

I am a real fan of ORM databases, and love this one called Red Bean PHP http://redbeanphp.com/ which allows you to quickly get a DB up and running, I used MySql for the database but for some projects I have used Sqlite. I do recommend MySql for you DB. Red Bean allows you to keep away from SQL (you can still uses it though) so you focus on manipulating object, not SQL statements.

For image manipulation and cropping. http://shiftingpixel.com/2008/03/03/smart-image-resizer/ which basically allows you to manage image resizing on the fly.  Super simple.

Finally after ChairBro was built I decided to create KLCK using the same engine but different design and different categories. Because I used Smarty for my templates I only had to create a new master template for the site and with some tweaks, I have 2 sites running of the same code base.

How big is it all. Well the 2 sites run off 1 index.php file which is about 900 lines long. This includes lots of comments and some other functions I am not using. 

Result: Love it. Its simple, separated, DB code is terse and concise, templates are logical and very easy to move around and manipulate. runs fast. 

Replies

Likes

  1. bluespark-blog posted this

 

Reblogs