A bridge that integrates PHP-DI dependency injection container with the Slim PHP micro-framework.
PHP-DI/Slim-Bridge is a package that integrates the PHP-DI dependency injection container with the Slim PHP micro-framework. It configures Slim to use PHP-DI as its container, enabling features like autowiring and flexible controller parameter injection. This solves the problem of managing dependencies and writing cleaner, more testable controllers in Slim-based applications.
PHP developers building applications with the Slim framework who want advanced dependency injection capabilities, such as autowiring and service injection in controllers.
Developers choose this bridge for its seamless integration of PHP-DI's powerful features into Slim, offering more flexible and maintainable code compared to Slim's default container. Its unique selling point is the ability to inject dependencies via type-hinting in both class-based and closure controllers, simplifying development.
PHP-DI integration with the Slim framework
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Leverages PHP-DI's autowiring to automatically resolve dependencies, reducing manual configuration and boilerplate code as highlighted in the documentation.
Allows controllers to accept parameters in any order, including route placeholders, request attributes, and services, simplifying request handling with examples in the README.
Enables writing class-based controllers with constructor injection, promoting better code organization and testability, as demonstrated in the UserController example.
Extends dependency injection to closure-based controllers via type-hinting, maintaining flexibility for micro-applications without sacrificing DI benefits.
Requires additional setup for PHP-DI definitions, which adds complexity compared to Slim's out-of-the-box container, especially for simple projects.
PHP-DI's autowiring relies on reflection, which can introduce minor performance overhead in high-throughput applications, a trade-off for flexibility.
Full documentation is hosted externally on PHP-DI's site, leading to a disjointed learning experience when integrating with Slim, as noted in the README.