1

I am new to the concept of MVC in php (or for that matter any programming language). I understand Model handles the business logic and the Controller is sort of a glue which interacts with the both the model and the view. I tired out a few examples given on Codeigniter. The examples show how you extend both Class Model and Class Controller and it works fine.

Looking at the core I find a few files and a core Controller and Core Model file. Since I am new to the concept of MVC I fail to understand what does this core controller and core model file do.

Can anyone please explain?

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
  • "the Controller is sort of a glue which interacts with the both the model and the view" - don't confuse [MVC with MVP](http://softwareengineering.stackexchange.com/questions/338143/what-are-the-improvements-of-mvp-over-mvc) as so many others have before you. – mister martin Dec 15 '16 at 18:47
  • @mistermartin, this is what I read "The final component of the triad is the Controller. Its job is to handle data that the user inputs or submits, and update the Model accordingly. The Controller’s life blood is the user; without user interactions, the Controller has no purpose. It is the only part of the pattern the user should be interacting with. " –  Dec 15 '16 at 18:53
  • I'm just pointing out that in MVC the logic should flow in a circular pattern. The view passes off to the controller, which then passes off to the model, and the model then updates the view. In other words the controller should never pass anything back to the view. Codeigniter gets this wrong. It is not valid MVC. – mister martin Dec 15 '16 at 18:56
  • "model then updates the view", correct me if wrong but I read somewhere "that both Model and View cannot call each other in a MVC, its the controller that Interacts with both of them" –  Dec 15 '16 at 19:02
  • That is half wrong. Please see the link provided in my first comment. – mister martin Dec 15 '16 at 19:12
  • @mistermartin, [link](http://stackoverflow.com/questions/1015813/what-goes-into-the-controller-in-mvc) –  Dec 15 '16 at 19:21
  • That link is outdated. MVC is concept that came from software, it was never intended to be used with stateless web applications. A lot of people get it wrong. But go ahead and do whatever you want. – mister martin Dec 15 '16 at 19:28

1 Answers1

0

They are simply the base classes for any custom controller or model class you create. So if you made your own controller:

class MyController extends Controller {

}

The Controller object here is CI's base Controller class.

thatidiotguy
  • 8,701
  • 13
  • 60
  • 105
  • yes here the MyController extends Controller to inherit the properties, methods of the base class. But what exactly is this base controller doing? –  Dec 15 '16 at 18:59
  • @NidhiVij Look at the code! If you're going to become a successful software developer you have to learn how to read other people's code. – thatidiotguy Dec 16 '16 at 14:37