Service Container là IoC (Inversion of Control) container quản lý các dependency của class. Thay vì tạo dependency thủ công, đăng ký một lần: app()->bind(UserRepository::class, MySQLUserRepository::class). Sau đó inject ở bất kỳ đâu: public function __construct(UserRepository $repo). Container tự động khởi tạo class đúng.
Lợi ích: một điểm để thay đổi implementation (swap repository dễ dàng), cấu hình tập trung, cho phép test với mock, lazy loading service. Truy cập trực tiếp: app()->make(UserRepository::class) hoặc dùng facade. Service Container là lõi của Laravel cho phép dependency injection toàn bộ ứng dụng.
Service Container is IoC (Inversion of Control) container managing class dependencies. Instead of manually creating dependencies, register once: app()->bind(UserRepository::class, MySQLUserRepository::class). Then inject anywhere: public function __construct(UserRepository $repo). Container automatically instantiates correct class.
Benefits: single point for changing implementations (swap repositories), centralized configuration, enables testing with mocks, lazy loading services. Access directly: app()->make(UserRepository::class) or use facades. Service container is Laravel's core enabling dependency injection throughout.