No one saw the label separating the obligations between the model and the controller? Clarify what functions belong to the controller in pkhp. I read a couple of articles, I realized that he was engaged in processing the parameters GET, POST and depending on their values, separate methods are called. I want to divide the code correctly between the controller and the model. Thank you. What part of working with a database refers to it? Where is the data validation? Form processing?

  • Tell me, why do not you use Google? - DreamChild
  • It may surprise you, but I was looking there. - koza4ok
  • 2
    depends on the ideology of the framework, if you write the framework yourself, then from your ideology. - zb '
  • one
    > Maybe it will surprise you, but I was looking there. Yes, it surprises me, because Google is full to the top with all sorts of information about the implementation of MVC, including specifically in php. - DreamChild

2 answers 2

Something like this: there is an index.php file in it, we look at the current URL and break it into its component parts with the help of explode, for example the URL was of this kind - - everything is simple, URL can be divided into user and register, where the user has the model name, then simply, when there is a model name, we can check its existence, and call it, also, if there is anything else, in this case register, in the case of OOP, this is the method ( function) and we will call it if there is no method, that is, like this: then in the model we should have an index () method that will be called if not other routers, also in htakces, we will need to redirect all requests to the index.php file

This is in the MVC design pattern like so) examples of MVC sea, google help

    The controller (English controller - controller, controller), Model (fr. Modèle, from latin. Modulus - “measure, analog, sample”) is a simplified representation of the real device and / or processes occurring in it, phenomena.

    those. we get all the logic and behavior described in the models and in the controller we manage these models