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

Amidamaru's avatar

What are Service Providers in Laravel?

In simple words.. What are Service Providers for in laravel?

Please let me know. Thanks in Advance

0 likes
3 replies
davestewart's avatar
Level 11

Simply? A scalable require();

When your app runs, it requires additional code, often packaged as "services" (See the "app/Services" folder) to get things done.

"Service Providers" are Laravel's way of packaging and managing the code needed to load these additional "services" (or running other code) at app bootup.

They are run in 2 phases - "register", and "boot"; each one defined by a same-named method on the provider.

The list of service providers for your app is listed in config/app.php, and this is how you specify which ones will run, and in what order (you don't need to run all of the service providers in the services folder, you can just keep them there, doing nothing).

When Laravel boots, it looks at the list, loads the right Providers, which in turn have their register() and boot() methods called at the right time.

Then the rest of the app boots, and subsequent tasks which need access to any "services" loaded by the "service providers", have them.

I was frustrated at how "codey" it all seemed at the start, but now I'm used to it, it's not a bad way to do things.

4 likes
martinbean's avatar

@Amidamaru Classes that provide a service for the application: https://laravel.com/docs/5.2/providers

Basically, features are wrapped up in ‘services’ that can be added or removed from the application, by adding or removing the corresponding service provider class. So things like routing, mail, etc. are services, and their functionality added to the Laravel framework via their service providers.

Please or to participate in this conversation.