حاوية الخدمات قوية جدًا:
ربط الواجهات بالتنفيذات
$this->app->bind(PaymentInterface::class, StripePayment::class);ربط Singleton
$this->app->singleton(ApiClient::class, function ($app) {
return new ApiClient(config('api.key'));
});الربط السياقي
$this->app->when(ReportController::class)
->needs(ReportInterface::class)
->give(PdfReport::class);يجعل حقن التبعيات الكود أكثر قابلية للصيانة والاختبار.