For a dependency injection container for PHP, the first results are symfony/dependency-injection (This is a comprehensive, PSR-11 compliant dependency injection container that provides robust support for autowiring, constructor injection, service configuration, and lazy loading, making it the industry standard for managing object lifecycles in PHP), php-di/php-di (This library is a comprehensive dependency injection container that fully supports PSR-11, autowiring, constructor injection, and lazy loading, making it a flagship tool for managing object lifecycles in PHP) and symfony/symfony (Symfony provides a highly robust, PSR-11 compliant dependency injection container that supports autowiring, constructor injection, and lazy loading, though it is a full-stack framework rather than a standalone library). thephpleague/container and rdlowrey/auryn round out the shortlist. Compare the match explanations and check the project documentation against your requirements.
We curate open-source GitHub repositories matching “best php dependency injection libraries”. Results are ranked by relevance to your query — pick filters below to narrow, or refine with AI.
This project is a PHP dependency injection container and framework designed to centralize object construction and manage class dependencies. It serves as a service container and configuration registry that automates object lifecycles and manages references between services to decouple application components from their specific dependencies. The system handles the instantiation and wiring of objects through both constructor and setter injection. It provides a centralized registry for storing reusable parameters and service definitions, which prevents the hardcoding of settings across the appli
This is a comprehensive, PSR-11 compliant dependency injection container that provides robust support for autowiring, constructor injection, service configuration, and lazy loading, making it the industry standard for managing object lifecycles in PHP.
PHP-DI is an inversion of control container designed to manage object lifecycles and dependency resolution within PHP applications. It functions as a centralized registry that automates the wiring of components, allowing for the decoupling of services from their concrete implementations. The library distinguishes itself by utilizing reflection to inspect class constructor signatures, enabling automatic dependency injection without requiring manual configuration for standard scenarios. It supports recursive resolution of dependency graphs and provides mechanisms for lazy object instantiation,
This library is a comprehensive dependency injection container that fully supports PSR-11, autowiring, constructor injection, and lazy loading, making it a flagship tool for managing object lifecycles in PHP.
Symfony is a full-stack web framework designed for building scalable and maintainable server-side applications. It provides a comprehensive collection of decoupled components that form a foundational architecture, centered on a robust dependency injection container and a configuration-driven routing engine. By organizing code into modular services, the framework ensures that application components remain testable and loosely coupled throughout the development lifecycle. The framework distinguishes itself through an event-driven kernel architecture that allows developers to intercept and modif
Symfony provides a highly robust, PSR-11 compliant dependency injection container that supports autowiring, constructor injection, and lazy loading, though it is a full-stack framework rather than a standalone library.
Small but powerful dependency injection container
This library provides a PSR-11 compliant dependency injection container that supports autowiring, constructor injection, and service configuration, making it a direct fit for managing object lifecycles in PHP applications.
IoC Dependency Injector
Auryn is a powerful dependency injection container that supports constructor injection, autowiring, and lazy loading, though it lacks native PSR-11 compliance.
This project is a shared technical specification and standard interface for dependency injection containers in PHP. It defines a common set of interfaces for retrieving services and dependencies, ensuring that different container implementations remain interoperable across the PHP ecosystem. By establishing a standardized API for dependency retrieval, the project allows developers to create libraries that function with any compliant container. This prevents vendor lock-in and enables different container implementations to be swapped without requiring changes to the application code. The spec
This repository provides the PSR-11 interface specification for dependency injection containers rather than an implementation that provides features like autowiring or service configuration.
This PHP routing library is an HTTP request router and matcher designed to map incoming URL paths to specific controller actions using defined patterns and configuration. It serves as a programmatic interface for defining, loading, and resolving URL patterns, while providing a URL generator to produce absolute or relative URIs from route names and parameters. The system supports diverse route loading through YAML, XML, PHP arrays, and class attributes, utilizing compiled route matching to optimize performance. It enables sophisticated request handling through regex-based path matching, sub-do
This is a routing component for mapping URLs to controllers, which is a different functional domain than a dependency injection container for managing object lifecycles.
This project is a full-stack web framework that provides a comprehensive environment for building server-side applications. It utilizes a model-view-controller architecture to separate application logic into distinct layers for data management, user interface presentation, and request handling. The platform manages the entire request-response lifecycle, including security, session handling, and background task processing, while using an object-relational mapping layer to translate database records into programmable objects. The framework distinguishes itself through a central service containe
While this framework includes a powerful dependency injection container, it is a full-stack web application platform rather than a standalone library for managing object lifecycles.
| Repository | Stars | Language | License | Last push |
|---|---|---|---|---|
| symfony/dependency-injection | 4.2K | PHP | MIT | |
| php-di/php-di | 2.8K | PHP | MIT | |
| symfony/symfony | 31.1K | PHP | MIT | |
| thephpleague/container | 867 | PHP | MIT | |
| rdlowrey/auryn | 724 | PHP | MIT | |
| php-fig/container | 10K | PHP | MIT | |
| symfony/routing | 7.6K | PHP | MIT | |
| laravel/framework | 34.8K | PHP | MIT |