๐ฉโ๐ฉโ๐งโ๐ฆBatch Registrar
Introduction
It streamlines the process of binding interfaces to classes in batch. It leverages a binding process to the service container, ensuring clean and maintainable code within the service provider.
How it works?
The package scans all .php files in the specified registrar paths, identifies valid bindable paths, and binds them to the service container. It specifically looks for the BatchRegistrar attribute. Learn more about PHP attributes here.
Service Provider
To use the batch binding feature, extend your service provider from CoreFoundationServiceProvider and utilize the batchRegistrar method.
class YourServiceProvider extends CoreFoundationServiceProvider
{
public function register(): void
{
$this->batchRegistrar([
__DIR__ . "/../Repositories"
]);
}
}Repository Interface
Define your repository interface with the BatchRegistrar attribute, indicating which class it should bind to.
Repository
Implement the repository interface to ensure it adheres to the specified structure.
Last updated
Was this helpful?