Problem
You want something to happen during the boot process.
You have a service provider you want to perform a specific task right before or right after the application is booted.
Solution
Use App::booting() or App::booted()
App::booted(function($app)
{
// Code to execute right after the app is booted.
});
App::booting(function($app)
{
// Code to execute right before the app is booted.
})
Discussion
Understand where this happens in the request lifecycle.
- First, all the service providers are booted.
- Next, any
booting()callbacks are called. - Finally, any
booted()callbacks are called.
