Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

> haddad_zineddine's avatar

Boot Methode in Service Provider

hello everyone i hope u are doing well ,

i have a question about service provider ,

can someone tell me when we use the boot function ? and why this methode in service provider

0 likes
3 replies
topvillas's avatar

Register happens when you register the provider and boot happens once all providers have been registered.

1 like
Tippin's avatar
Tippin
Best Answer
Level 13

@jokerdz Boot is what is loaded once all providers have registered their bindings to laravels service container. Example would be the very default RouteServiceProvider in a base laravel install. The "Router" is built into the framework, but must be bound to the container so whenever you call to resolve the router | Route::class facade, the container knows what to give you. Once the container knows what to resolve, you can "boot" the service and do any logic you want to set for the provider in boot, knowing it can be resolved. Look at the default route provider and behind the scenes laravel did the "register" part for you, but you are free to use boot to "setup" the routes now that the router class is available.

https://github.com/laravel/laravel/blob/8.x/app/Providers/RouteServiceProvider.php#L36

https://laravel.com/docs/8.x/providers#the-boot-method

1 like

Please or to participate in this conversation.