How the request handler works with MVC pattern in laravel..

raidah_fairuz

Raidah Fairuz Nashra

Posted on November 25, 2023

How the request handler works with MVC pattern in laravel..

In laravel POST method is used to send the request to the server to create and update resources. Request handler manages the incoming HTTP request and prepare the controller to process the request through MVC. MVC contains Model, View and Controller. The over view:

  1. Routing: At first the http request goes throungh the routing system. In "web.php" file we define the Route method POST/GET/PUT/PETCH. create the link, give a controller method name and send it to controller.

2.Middleware: Before reaching the controller to process the http request goes through the Middleware. It decides the request is acceptable or not.it is like a filter/guard. We can filter and modify the request. Authentication, modification, logging those are done by middleware.

3.Request Object: After passing from middleware,request object encapsulates the information of the request. When a form is submitted the data of form is stored in "request object" and we fetch the data via "request object".

4.Controller dispatch: Laravel dispatches the request to the appropriate controller method based on the route definition.

5.Controller Logic: We make controller. Controller is a special class in laravel, it helps to reuse our code. in controller we call the methods, rettrive data, do interaction with models. In this page we prepare the response and return the view.

6.Responce: Controller page send the response to .blade pages. In ".blade.php" we show the result/response.it is a page of json data, file or html template.

7.Middleware (After response): Lastly the result again go through the middleware. we can modify the result before sending it to the client.

πŸ’– πŸ’ͺ πŸ™… 🚩
raidah_fairuz
Raidah Fairuz Nashra

Posted on November 25, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related