In this blog post I talk about Laravel's Service Providers and about its life cycles.
In brief, a Laravel application is bootstrapped (started) whenever a webrequest hits index.php in the public folder, or when an artisan command is executed. Tough both the index.php and artisan file work very similarly, I will only talk about index.php.
When the index.php file is called it registers the autoloader. After that Laravel's Application is initiated and stored in the $app variable which is used to construct a kernel that manages the input and output of our app.
After handling the input by our $kernel it returns a $response object which is send back to our visitor.
Let's rewind a bit, there are four1 important things that are done in the index.php:
- The autoloader is registered
- Laravel's
Applicationclass is initiated and stored in$app - A kernel is constructed using the
$app's Service Container.