T
T
topuserman2020-04-01 23:40:44
PHP
topuserman, 2020-04-01 23:40:44

What is mvc pattern really?

I have been engaged in web development for more than 8 years, of which 5 years of commercial experience.
Due to the specifics of the industry in which I work (cms with the letter B ), I did not have to deal with the mvc pattern.

There were many attempts to figure it out, I read tons of articles of the same type, where the whole essence of the pattern is described by a similar scheme:
01cc4f3f2646eaea356bc50dccce40d6.png
but nothing is clear.
I want to figure out what entities, where we take out, for what, etc. , preferably on different examples.

Some articles mention different layer architectures like:

controller-service-repository
repository-service-controller-view
и т.д..

but what it is in general, how it is used, what other types there are, what problems solve it is not described.

Tried to study code examples on github.
also many questions.
Looking at the file structure of the projects, I see the same folders:
repositories
services
views
controllers
entities
и т.д.


it is also not clear what entities are stored in them, according to what logic the separation of entities occurs and what kind of connections they have, and most importantly? What problem is each solving?

Please tell me how can I figure this out? what to read?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
N
Northern Lights, 2020-04-02
@php666

Put this solution on the basis of the Laravel framework - laravel-boilerplate.com
This is an application framework with some ready-made modules, it will be easier to understand by the already written code of the modules. We have colleagues who have worked with Bitrix all their lives and did not know anything about MVC, they understood the principle in a week, based on code examples.
To understand MVC, you need to understand the essence of OOP. To understand the essence of OOP, you need to read the relevant literature . It is important. You need to learn how to think with objects , forget like a bad dream everything you knew before and re-learn how to write code.
To understand what the division of the system into layers is, you need to read this (start right away from part 1, chapter 1).
Well, on, my articleon a more "human" version of the understanding of the MVS.

X
xmoonlight, 2020-04-02
@xmoonlight

The easiest way to explain this is with a function example:
1. Parameters are the controller.
2. The body of a function is a model.
3. The result (returned to the call site) is a view.
MVC is the same thing, but a different name for a different complexity of logic.

A
Alexander, 2020-04-02
@Survtur

Model is a database, possibly with validation checks.
Controller is an API + partially a frontend that interacts with this API.
View is what the user sees.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question