I’ve mentioned CodeIgniter a few times in the past; it’s a PHP Framework modeled somewhat (I’m told) after Ruby On Rails, without the annoying Ruby part. I’ve downloaded it multiple times in the past and attempted to do something with it, but as usually I didn’t quite know where to start. Sure, I could have grabbed a tutorial, but there is a very specific way I learn and oftentimes I need to reformat the material to compensate for inaccuracies and ambiguities in the writing. Not efficient, usually frustrating, and so I avoid it.
I recently had the opportunity to work with someone else’s CodeIgniter project, and he gave me the 10-minute overview, which I will boil down into the following steps:
- Installation consists of dropping the “system” folder and index.php file to your website. The index.php file is the “application start”, which points to all sorts of stuff in the system folder.
- CodeIgniter interprets URLs as commands, starting with everything after the index.php. For example, the url http://mysite.com/index.php/hello/there/sam runs a command “hello” with the method “there” with the parameter “sam”.
- CodeIgniter “routes” commands to a Controller (as in a Model-View-Controller pattern) . The command is the name of the controller file, in this case “hello.php”. The method corresponds to a function name in the controller file.
- Each Controller can manipulate data through the Model class, and load web pages through the View class.
- Controllers, Models, and Views all live in the system/application/ folder.
The rest of CodeIgniter is helpful classes to do things, like generating form data and accessing databases. What I like about it is that it provides a nice structure to develop PHP applications using some form of best practices. I just never knew where to START with these things.
My first CodeIgniter project is the “contact me” form on my design website. It does all kinds of form validation and then sends me an email in a NICE way. And, by using their provide form_validation class, it didn’t take the days it would have otherwise taken me to learn how to make this. It did take 8 hours of learning how it worked on-the-fly, but they were hours well spent figuring out how I wanted this to work.