1. Today
  2. Monday Jul 06, 2020

image description

Learn CodeIgniter from Scratch by Building a Project (002 - Understanding MVC)

Hey guys, this is second part of the series, and in this part we will be taking a deep look at what is Model – View – Controller (MVC) and why we use it and how to take maximum advantage.

If you are a PHP developer (I assume you are) you will know that creating a full web application require more than just PHP, we have to use HTML, CSS, JavaScript (jQuery, VUE.js) and PHP itself along with Database queries. For a small application there is nothing to worry about, but as your application expands and all the aforementioned technologies were used, things begin to get out of hand and the code will be mixed-up so badly that after a short while it will look like a spaghetti of code, which in turn makes the application more error prone and difficult to debug in the future.

To overcome the problem developers came out with the idea of MVC (Model – View – Controller). The idea behind MVC is to split the app in three major areas:

  • Models
  • Views
  • Controllers

And each area should be responsible for its own tasks and objectives.


Models held all the logic building and the database queries.

Views :

Views will held all the HTML,CSS and JavaScript that makes up the attractive UI/UX.

Controllers :

Controllers will be responsible for all the authentication and business logics and connects the models with views.

If a developer keep in mind the above sections properly, the application will be more manageable and less error prone, and believe me it will make life much easier when you want to make changes to a project in future.

Luckily, CodeIgniter is built using MVC and we will take full advantage of MVC throughout the series . So don't be afraid or get confused if the MVC picture is still foggy, I know, I been there, but just trust on me and finish the series with me, I promise you once we are done you are a master of MVC and CI3.

That is all for this tutorial, see you in the next part

Load WordPress Sites in as fast as 37ms!
image description


Iftikhar is a full stack developer with a passion of data mining, bot making and ethical hacking. He is working as a project manager at mazoon software company located in oman.

Comments (0)

Post Your Comments