Search code examples
laravellaravel-5

Diagram of laravel architecture?


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.


Solution

  • 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 handler (Controller).

    Points to Remember:

    MVC stands for Model, View and Controller. The Model is responsible for maintaining application data and business logic. The View is a user interface of the application, which displays the data. The 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: The Laravel way for filtering HTTP requests entering your application. It sits after the router and before the 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.

    Source: 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.

    Source:: https://laravel.com/docs/5.6/contracts

    enter image description here

    Image source: 10 quick tips to get better at Laravel