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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners