MdaUZH2016-01-18 12:10:05
MdaUZH, 2016-01-18 12:10:05

A couple of questions about MVC?

Hello everyone, the topic is hackneyed, I understand, but I could not find a clear answer, and this ambiguity is embarrassing ..
Some do not relate directly to MVC, but still.
Here's what you're interested in:
1. In public_html, only the Front controller and public data (pictures, videos, css, js files) - right?
2. All checks are performed "at the http level in the controller" - for example, is the user authorized and so on - right?
3. Shaping the response in the controller or in the model?
3.1 here opinions differed and each post about it repeats its own, someone says that the model should be slim and have only work with the base (that is, it checked, got it, gave it away), and then everything that the controller decides to say, someone thinks that it is better to form a response in the model (for example, if something is wrong with the selection from the database, return an error)
and the phrase "http level" was also confused - what does this even mean?
context - "all checks at the http level", meaning the controller, I didn’t really understand it
Thank you all in advance :)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
eclipse20, 2016-01-18

1) In public_html (if you mean the web server folder), then there should be a script that loads the MVC framework or the V part i.e. View
2) Authorization and authentication must be done before calling part C i.e. Controller-a
3) Only in the controller, in the models, prepare the code that works with the database, and transfer the prepared data to the model.
3.1) By "generate a response" most likely it was meant to prepare data for sending, for example, transfer it to a field, etc.

Alexander, 2016-01-18

1) in the public html input front script index.php and folder with resources, that's all. The rest is either in the protected folder or at a higher level.
2) The controller + can do filters so as not to copy-paste the code
3) The controller takes the request input, gives it to the model layer, the model gives something, the controller processes it into the desired response format and shoves it into the view.
4) Models: entity + logic layer is better.
Depends on the pattern (AP, Date mapper, etc.). But to separate the work with the database and the business logic itself is unequivocal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question