Service Provider for Product Domain
The ProductServiceProvider binds all product-related services, repositories, queries, and filters into the Laravel service container.
• Singleton bindings for stateless classes
• Dependency injection ready
• Centralized service registration
Complete Implementation
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\Repositories\ProductRepository;
use App\Services\ProductService;
use App\Queries\ProductQueries;
use App\Filters\ProductFilter;
use Illuminate\Http\Request;
class ProductServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->app->singleton(ProductRepository::class, function ($app) {
return new ProductRepository();
});
$this->app->singleton(ProductQueries::class, function ($app) {
return new ProductQueries();
});
$this->app->singleton(ProductFilter::class, function ($app) {
return new ProductFilter($app->make(Request::class));
});
$this->app->singleton(ProductService::class, function ($app) {
return new ProductService(
$app->make(ProductRepository::class),
$app->make(ProductQueries::class)
);
});
}
public function boot(): void
{
}
}
💡
Key Features
• Singleton bindings for stateless services
• Dependency injection for all product domain classes
• Centralized and maintainable service registration