Step 1: First contact – What is MVC and what is CodeIgniter

(created: November 14, 2014; last update: January 12, 2015)

OK… You are a bit knowledgeable regarding PHP, you are proficient at creating spaghetti code, and you know a thing or two about OOP. Then, someone comes to you and says something about MVC. You say “Riiiiight…”, and do your best not to betray the fact that you don’t know a darn thing about what MVC is.

So you go to Wikipedia and write “MVC” in the search form.

“Model–view–controller (MVC) is a software architectural pattern for implementing user interfaces. It divides a given software application into three interconnected parts, so as to separate internal representations of information from the ways that information is presented to or accepted from the user.”

“Wow… Why didn’t I think of that?”, you say to yourselves. After a bit of reading you find out that:

A controller can send commands to the model to update the model’s state (e.g., editing a document). It can also send commands to its associated view to change the view’s presentation of the model (e.g., by scrolling through a document).

A model notifies its associated views and controllers when there has been a change in its state. This notification allows the views to produce updated output, and the controllers to change the available set of commands. In some cases an MVC implementation might instead be “passive,” so that other components must poll the model for updates rather than being notified.

A view requests information from the model that it uses to generate an output representation to the user.

After that you can absolutely say “YES! I KNOW WHAT MVC IS!!!”. But how can you implement something like this in PHP? The easiest thing, you might say, would be to create your own MVC structure and start from there (a great tutorial about that would be PHP Academy’s). But after a lot of tries and fails you say: “F*** IT!” and look for a well established MVC framework.

If you do a Google search you will find a lot of alternatives. But I will assume that if you got to this page, you’ve found CodeIgniter to be of your liking.

So, download a fresh copy of CodeIgniter, put it inside your server’s public folder (or wherever you want it to be), and see if all went well.

Of course you can also download CI 2.2.4, but I would advise you to install version 3, even if it is in development stage.

For this tutorial we will put it inside htdocs (I will suppose that you have XAMPP installed).

Now, if you visit “http://localhost” you should see your new CodeIgniter “site”…

0 thoughts on “Step 1: First contact – What is MVC and what is CodeIgniter

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

No spam? * Time limit is exhausted. Please reload CAPTCHA.