How Laravel Works (Part 1)
Laravel has became the most popular framework for PHP. In this tutorial I’d like to show you how Laravel works in deep. knowing how Laravel works helps you to improve your code styles.
As Laravel is being changed frequently, we’ll discover Laravel’s philosophy according to version 5.8.
Starting Point Of Laravel Framework
Entry point of a Laravel application is public/index.php which run the application and send the response back to client.
So let’s see what happens when index.php is called :
First of all, the Framework defines a constant named LARAVEL_START which is never used. packages like laravel-debugbar use this constant to determine the execution time of a request.
As you (should) know, Laravel uses Composer to manage dependencies and auto loading, So auto loader is included at line 21.
At line 44, An instance of Kernel class which is dedicated for HTTP requests is resolved from IoC container. Then an instance of Request class is passed to Handle method of Kernel class. From This method, Middlewares are applied and Proper route action in called and a Response is returned. (We will cover more about this pipeline later).
Finally the request is sent to the browser using send method of Response class.