First Thoughts on Codeigniter and MVC

Date Posted: 02/23/2010 - 04:19 am  

After falling into web development, I wasn't sure what programming language to use. 'Web' programming languages I knew were Python, Ruby, and a little PHP. While I really like the speed and 'feel' of Python, and heard (many, many, many) times about how cool Ruby is (it is. more on that later), I chose PHP. I knew that there were many popular sites written in PHP, every hosting company supports PHP, and it has a 'similar' syntax and flow as my background (C). I know there are millions of people who hate PHP, and I actually agree with a few of their arguments (Though a good programmer should know to sanitize input (RE: PHP == exploits)). I realized that PHP, like Perl, allowed me to hack up a solution easily and quickly, albeit the end result may be a bit ugly. Well this is where Codeigniter (CI) and Model-View-Controller (MVC) come to play. Four years and 15 or so projects later, I realized that, with PHP, my code is not very pretty. Read that as, I would be embarassed if someone had to maintain/debug/(and in some cases)see my code. Now this is not PHP's fault, I actually like the fact that I can always hack something together and make it work, but I would like a little more 'constraint' with how lazy I can get. So two weeks ago I agreed to finally give a PHP framework a go. I had heard much about the Zend framework, CakePHP, the Yii Framework and Codeigniter (among others). I choose to use CI because it is easy to install & configure, very fast, lightweight, and while I wanted some 'code constraint', I don't have to live by CI's coding rules.

After two weeks of usage (building this here blog) I realized how much I enjoy the simplicity of the MVC pattern. I feel it has quickly improved the readability of my code just by seperating the logic from the frontend and database functions. I also have been enjoying CI's features like creating google-friendly URLs with the URI class, the excellent active record class for DB use, and I enjoy, but want to test more, the security helper, specifically the XSS_clean() function.

Anyway, there it is. So far so good. I plan to write some more articles on CI and specifically how to build a site like this. Please leave a comment if you know more about CI's built in XSS function and/or any tips you may have for me as I begin my CI journey.

0

comments