Notes on codes, projects and everything

MVC : Me vs. CodeIgniter

CodeIgniter’s Implementation

Before I start, I would have to say that I am new to CI and this post is written before I actually start developing using CI. The following code is mainly based on the tutorial screencasts and the official user manual. This post is written just to highlight the differences between our implementation and that’s all.

Because CodeIgniter is a full-featured framework, hence the developer doesn’t have to worry about file inclusion and other stuff as long as he/she develops the site according to some simple guidelines.

Model

Because CI doesn’t care about three-tier architecture, so there are only three parts in their MVC implementation. The first is the Model and a typical model would look something like the following (taken from the manual)


class Model_name extends Model {
 
function Model_name()
{
parent::Model();
}
}

View

The view to display output. I haven’t start digging the code to see how the passing of message is done but it seems that the information comes from the controller? (The code snippet below is taken from the manual)


<html>
<head>
<title><?php echo $title;?></title>
</head>
<body>
<h1><?php echo $heading;?></h1>
</body>
</html>

Controller

The url structure of CI is explained here. Therefore basically the first part of the url is the module, followed by the method name and the parameter as below

http://www.id.tld/module_name/method_name/parameter/

And the code which corresponds to the URL (Again, the following code is taken from the manual)


<?php
class Blog extends Controller {
 
function index()
{
echo 'Hello World!';
}
 
function comments()
{
echo 'Look at this!';
}
}
?>

Conclusion

To port my current development project to CI, I would have to either rewrite my MVC architecture or find a way to integrate my MVC implementation to CI’s MVC implementation. I really hope that I do not have to rewrite everything again just because I want to use CI.

leave your comment

name is required

email is required

have a blog?

This blog uses scripts to assist and automate comment moderation, and the author of this blog post does not hold responsibility in the content of posted comments. Please note that activities such as flaming, ungrounded accusations as well as spamming will not be entertained.

Pings

Click to change color scheme