quillphp/container

First-class DI container with autowiring for Quill PHP

Maintainers

Package info

github.com/quillphp/quill-container

Homepage

pkg:composer/quillphp/container

Statistics

Installs: 11

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.0.1 2026-04-06 13:28 UTC

This package is auto-updated.

Last update: 2026-04-06 13:41:25 UTC


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.