Laravel has a fantastic dependency injection container, yet many people shy away from it. In this tutorial, I will walk through how I lean on Laravels container to make my code work for me.

We start with maybe 5-6 bindings for a simple application, add several new features, and need to add bindings to the container.

{ $this->app->register( provider: AuthDomainServiceProvider::class, ); $this->app->register( provider: CommunicationDomainServiceProvider::class, ); $this->app->register( provider: WorkDomainServiceProvider::class, ); }}

Of course, I keep the other default service providers with a Laravel application, as they have their purpose.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners