Category: Laravel

When binding services into the container, usually we use the register() method, which is the dedicated method for this. However, there is another quick way to bind services. Let’s take a look, how do we use the register method usually: This is the generic way to register services, and we need to go this way when we want to customize the service a bit. However, when our service is quite simple, we can skip the register method, and use the $bindings and $singletons property: Using this approach, we can clean up our register method a bit. This is useful when we are registering a bunch of different services, so the simpler ones, we can refactor to a property instead of populating the register method more.

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

Community Partners