If Laravel was a house, Service Providers would be the electricians, plumbers, and carpenters who set everything up before you move in.
In simple words:
Service Providers are the central place where Laravel loads and registers everything your app needs before it starts running.
Without them, Laravel would be like a shop without shelves — nothing in place to start business.
All Service Providers live in the app/Providers folder.
Laravel comes with some pre-installed Service Providers in Laravel 12 like:
AppServiceProvider
You can create your own too.
Every Service Provider has two main methods:
1. register() – This is where you tell Laravel what to load into the Service Container.
public function register()
{
$this->app->bind('MyService', function () {
return new \App\Services\MyService();
});
}
2. boot() – This is where you do things after all services are registered.
public function boot()
{
\Log::info('App is booting...');
}
php artisan make:provider MyServiceProvider
Then, register it in bootstrap/providers.php:
return [
App\Providers\CustomProvider::class,
];
Service Providers = Laravel’s setup team
register() = Prepare tools
boot() = Start working
They make Laravel ready to run in an organized way.