Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Diagram of laravel architecture?

Tags:

Can anyone point me to a diagram that shows the relationship between the normal MVC bits and the following:

  • middleware
  • Guards
  • facades
  • Contracts

Laravel seems to have so many middlemen and I'm struggling to see the big picture.

EDIT

After thinking about Alex's answer (below) I'm thinking that such a diagram is possible. Since some of this relates to general OOP principles, I thinking that a UML Sequence Diagram would be the answer.

like image 747
Maxcot Avatar asked Jul 15 '16 10:07

Maxcot


2 Answers

Sorry. It is not an answer. But just some opinion.

You are trying to compare "apples" with "oranges".

MVC concept is a concept related specifically or mostly to WEB development.

It recommends developer to not mix content (Model) with representation (View) and with logic (Controller).

On other hand things you've mentioned: middleware, Guards, facades, Contracts.

They all are mostly about general programming concepts and kind part or an extentions of OOP principles.

Let not talk about your specific terms: middleware, Guards, facades, Contracts, but just about OOP.

Any OOP principle can be applied to any part of MVC.

We can create Model using OOP (classes, interfaces, etc) or we can do it some procedural way or mix of OOP, procedural and classic spaghetti.

Same about View and Controller. You can use some OOP principles and techniques or you can limit usage of those or ignore them. That is up to developer and/or probably it depends on the project scope and design.

Coming back to your list: middleware, Guards, facades, Contracts. I would say those are just part of a big family of OOP terms and practices existing in modern software development world. I mean unfortunately we can not do any parallels between MVC and some list of OOP practices.

Another idea I would point is that OOP is much more general than MVC, WEB and data-representation-logic kind software.

Let say we need to develop new OS kernel. I would say there is no that much room to apply MVC for such application. But OOP could be still usefull. Same about embedded systems, or some specific software, drivers, servers, etc...

like image 30
Alex Avatar answered Oct 04 '22 17:10

Alex


As Your question is very broad, I think providing explanation for all in one image would be like having all flavor in single cake. @Alex in above answer, already have covered the explanation precisely. Here is my take :

MVC : A design pattern recommends developer to not mix business logic (Model) with representation (View) and with user's requests Hander (Controller).

Points to Remember :

MVC stands for Model, View and Controller.
Model is responsible for maintaining application data and business logic.
View is a user interface of the application, which displays the data.
Controller handles user's requests and renders appropriate View with Model data

More details : http://www.tutorialsteacher.com/mvc/mvc-architecture

Terms: middleware, Guards, facades, Contracts are part of application logic of Laravel framework for request cycle at different use-cases, to segregate codes in the application to improve maintainability, understand-ability and cohesiveness. Though even a single page script is enough to do the needful job but it will be a headache to maintain.

middleware : Laravel way for filtering HTTP requests entering your application. It seats after router and before controller in the request life cycle.

More info : https://laravel.com/docs/5.6/middleware

Guards : They're the definition of how the system should store and retrieve information about your users while registration and authentication.

More info : https://laravel.com/docs/5.6/authentication

facades : Facades provide a "static" interface to classes that are available in the application's service container. https://laravel.com/docs/5.6/facades

Contracts : For loose coupling and simplicity. Laravel's Contracts are a set of interfaces that define the core services provided by the framework. For example, a Illuminate\Contracts\Queue\Queue contract defines the methods needed for queueing jobs, while the Illuminate\Contracts\Mail\Mailer contract defines the methods needed for sending e-mail.

More details : https://laravel.com/docs/5.6/contracts

enter image description here

like image 112
Amitesh Bharti Avatar answered Oct 04 '22 15:10

Amitesh Bharti