quillphp/container
最新稳定版本:v0.0.1
Composer 安装命令:
composer require quillphp/container
包简介
First-class DI container with autowiring for Quill PHP
README 文档
README
First-class Dependency Injection container with zero-config autowiring for the Quill PHP Framework.
This container implements PSR-11 and provides a fast, reflection-based autowiring mechanism that eliminates the need for manual service configuration in most cases.
Installation
composer require quillphp/container
Features
- PSR-11 Compliant: Seamless integration with any PSR-11 compatible library.
- Recursive Autowiring: Automatically resolves and injects constructor dependencies.
- Singletons: High-performance instance caching for shared services.
- Interface Decoupling: Bind abstract interfaces to concrete implementations.
- Circular Detection: Fail fast with clear error messages when circular dependencies occur.
Usage
Basic Autowiring
Simply request a class, and the container will instantiate it and all its dependencies:
use Quill\Container\Container; class Mailer {} class UserController { public function __construct(private Mailer $mailer) {} } $container = new Container(); $controller = $container->get(UserController::class); // Works out-of-the-box!
Manual Bindings
Singletons
Register a service that should only be instantiated once:
$container->singleton(Database::class, function($c) { return new Database(getenv('DB_URL')); });
Interface Implementation
Tell the container which concrete class to use for an interface:
$container->bind(UserRepositoryInterface::class, SqliteUserRepository::class);
Integration with Quill App
Quill automatically uses this container for resolving handlers:
$app = new \Quill\App(); $app->singleton(MyService::class); $app->get('/users', function(MyService $service) { // service is already resolved and injected! });
License
This package is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 16
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-06