Model view controller in Laravel - MVC

- Andrés Cruz

En español
Model view controller in Laravel - MVC

The MVC pattern is one of the many software design patterns that exist today, one of the most widely used and from which numerous variants such as MTV, MVP, MVA, MVVM and many others arose; as you can suppose, it is a scalable, adaptable pattern and if it has so many variants it means that it has great potential; frameworks like Laravel and of course CodeIgniter use it to organize our code, make it easy to maintain, adapt changes, maintain it and other aspects related to the guidelines that we must follow to develop any type of application.

Laravel uses the Model, View, Controller (MVC) pattern; this keeps each layer as separate parts, but works together as a whole:

  1. Models manage the application’s data and help enforce any special business rules that the application might need. 
  2. Views are simple files, with little or no logic, that display information to the user; they are composed of HTML for the static part and PHP for the dynamic part; aside from CSS and JavaScript. 
  3. Controllers act like a sticky code, sorting data between the view (or the user viewing it) and the data store, i.e. the model; this component is where we generally spend more time (along with the view), since we have to organize everything that we are going to see in the view, apply validations and other rules according to the logic that we program in our application. In their most basic form, controllers and models are simply classes that have a specific job that we noted above; but, there are always processes that we can reuse and we do this by defining other classes such as services, help files, etc; that can be part of the core, that is, part of the framework, or can be defined by you, as part of the application you are creating or by third parties, installed or copied into the framework.

In their most basic form, controllers and models are simply classes that have a specific job that we noted above; but, there are always processes that we can reuse and we do this by defining other classes such as services, help files, etc; that can be part of the core, that is, part of the framework, or can be defined by you, as part of the application you are creating or by third parties, installed or copied into the framework. 

It is important to point out that Laravel is one step ahead of MVC since it has evolved so much that it is not a pure MVC to put it in some way; we can define the same MVC logic in many ways; for example for controller we have 3 ways to do the same thing using routes, controllers and components; in a few word, to test the above, just check the Http folder of the framework:

MVC folders
MVC folders

Which, as we mentioned before, is the one used so that a client can consume the application through HTTP; you will see that the controllers folder is just a part of the Http folder; but we point out the MVC as a part to understand the basic flow. 

In Laravel we have folders designated for a particular task; as we explained above; we as developers are going to spend most of our time in the /app call and the /resources folder.

Laravel is a huge framework, with multiple tools that it provides us to create true current, maintainable and scalable applications. In a Laravel project, apart from being able to develop in the framework itself, we can also develop in Node; therefore, we have two huge worlds in the same project. 

Even so, it is a good choice to learn to programing in Laravel and with this, take the first steps.

It all starts with the MVC, which is the beginning of everything and is the heart of the framework; but, as with other frameworks, such as CodeIgniter or Django, there is one more layer in which we can perform some tests, which in this case would be the routes.

Andrés Cruz

Desarrollo con Laravel, Django, Flask, CodeIgniter, HTML5, CSS3, MySQL, JavaScript, Vue, Android, iOS, Flutter

Andrés Cruz en Udemy

Acepto recibir anuncios de interes sobre este Blog.

!Cursos a!

10$

En Udemy

Quedan 1 días!

Udemy

!Cursos desde!

4$

En Academia

Ver los cursos

!Libros desde!

1$

Ver los libros
¡Hazte afiliado en Gumroad!
!Web Alojada en Hostinger!