Laravel (5.7) Request Lifecycle
It's important to understand the inner workings of any tool you are given to work with, a complete understanding of that tool will enable you to use all the power that comes with the tool. In this case, understanding how laravel works under the hood will help us utilize all of it's awesome "power". When we want to learn more about the laravel framework, the request lifecycle is the best place to start. It defines what's happening between an http request to our application till the response. Looking at the request lifecycle in depth will help us understand laravel’s structure better.
Everything in a laravel application starts from the index.php file found in the public directory. The index.php file is so important because any call or request into our application will initially route to it. In the index.php file, the application gets stored as an application instance, which could also be called a service container. Behind the scenes, different things are happening in the service container. One of which is the registration and storage of core classes that can be used later.
The HTTP Kernel is located in the app/Http/Kernel.php , all the application's middlewares are registered in this file such as the middleware groups and the route middlewares. The http kernel is the next place the incoming request is sent to. It receives a request and returns a response. All of this is accomplished by the handle method available to the Kernel class. Once the handle method recognises a HTTP request, it returns a HTTP response. The Kernel class extends the Illuminate\Foundation\Http\Kernel class which contains a bootstrap method. This method checks if our application has been bootstrapped already. If not, the bootstrap method runs on a bunch of classes to bootstrap the application. It loads the configuration file, loads also the environment variables, handles exceptions, registers facades and also registers the application’s service providers. The application's default service providers are stored in the app/Providers directory.
- Exercises: Weekly Top 16 Most Popular Topics
- SQL Exercises, Practice, Solution - JOINS
- SQL Exercises, Practice, Solution - SUBQUERIES
- Java Array: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : Conditional Statement
- HR Database - SORT FILTER: Exercises, Practice, Solution
- C Programming Exercises, Practice, Solution : String
- Python Data Types: Dictionary - Exercises, Practice, Solution
- Python Programming Puzzles - Exercises, Practice, Solution
- C++ Array: Exercises, Practice, Solution
- C# Sharp Basic Algorithm: Exercises, Practice, Solution
- Python Lambda - Exercises, Practice, Solution
- Python Pandas DataFrame: Exercises, Practice, Solution
- Conversion Tools