# Service Providers
Estimated time: 6 minutes
Difficulty: Intermediate
Service providers are the bootstrap layer of LaraCoreKit and each module.
Why Providers Matter
Service providers tell Laravel how to wire your application:
- Register services in the container
- Load routes/views/translations/migrations
- Bind interfaces to implementations
- Register event listeners and commands
Provider Types in LaraCoreKit
AppServiceProvider- global app bootstrapping.ModuleServiceProvider- discovers and registers modules.*ModuleServiceProvider- one per module.
Typical Module Provider
class BlogServiceProvider extends ServiceProvider
{
public function register(): void
{
// Bind services or merge config
}
public function boot(): void
{
$this->loadRoutesFrom(__DIR__.'/routes/web.php');
$this->loadViewsFrom(__DIR__.'/resources/views', 'blog');
$this->loadMigrationsFrom(__DIR__.'/Database/migrations');
$this->loadTranslationsFrom(__DIR__.'/resources/lang', 'blog');
}
}
Register vs Boot
-
register():- Container bindings
- Config merge
- No runtime dependencies
-
boot():- Route/view/migration loading
- Event registration
- Runtime-ready logic
Best Practices
- Keep providers lightweight.
- Avoid heavy DB queries in
boot(). - Use dedicated classes for complex registration logic.
- Namespace module views/translations.
Next Steps
Next: Routing →