Laravel Auto Binder: Bind Interfaces to Implementations Automatically

Packages

December 24th, 2021

laravel-auto-binding-featured.png

Laravel Auto Binder is a package by Michael Rubel that binds interfaces to implementations automatically. This package automatically binds interfaces to implementations in the Service Container, scanning the specified project folders. This helps avoid manually registering container bindings when the project needs to bind many interfaces to its implementations without any additional dependencies.

Given the following file path conventions, your implementations are automatically available in the service container:

1namespace App\Services;
2 
3use App\Services\Interfaces\ExampleInterface;
4 
5class ExampleService implements ExampleInterface
6{}

The package's configuration gives you the option to change the convention of where to look for contracts and implementations. You have complete control over the type of bindings, interface naming conventions, and folders to scan.

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.