Lifecycle case study of Laravel request
This article focuses on "Life cycle case Analysis of Laravel requests". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "the life cycle case study of Laravel request".
Laravel is a powerful PHP framework, and when you learn about the laravel framework, the Laravel request life cycle is the best starting point. This article describes what happens when a HTTP request is received and responded to in Laravel. An in-depth study of the request life cycle will help us understand the structure of the Laravel. (based on Laravel 8)
There are different terms for the request life cycle, such as autoloader, kernel, service provider, scheduling request, and routing. Once you have a detailed understanding of all the terms, you will have a better understanding of the framework and can extend different functions as much as you like.
The first step in the Laravel request life cycle overview
Load project dependencies and create Laravel application instances
The entry point for all requests of the Laravel application is the public/index.php file. All requests are directed to this file by your web server (Apache/Nginx) configuration. That index.php file doesn't contain much code. Instead, it is the starting point for loading the rest of the framework.
# 1. Loading a project depends on require_ _ DIR__.'/../vendor/autoload.php';$app = require_once _ _ DIR__.'/../bootstrap/app.php'
The index.php file loads the autoloader definition generated by Composer, and then retrieves an instance of the Laravel application from bootstrap/app.php.
Bootstrap/app.php: