Register happens when you register the provider and boot happens once all providers have been registered.
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
@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
Please or to participate in this conversation.