gacela-project/resolver

This package is abandoned and no longer maintained. The author suggests using the gacela-project/container package instead.

A minimalistic container dependency resolver

Maintainers

Package info

github.com/gacela-project/container

Homepage

pkg:composer/gacela-project/resolver

Transparency log

Fund package maintenance!

chemaclass.com/sponsor

Statistics

Installs: 15 611

Dependents: 0

Suggesters: 0

Stars: 11

Open Issues: 0

0.10.0 2026-07-19 22:59 UTC

README

GitHub Build Status Scrutinizer Code Quality Scrutinizer Code Coverage Psalm Type-coverage Status MIT Software License

A minimalistic, PSR-11 compliant dependency injection container with automatic constructor injection and zero configuration.

Features

  • 🚀 Zero Configuration: Automatic constructor injection without verbose setup
  • 🔄 Circular Dependency Detection: Clear error messages when dependencies form a loop
  • 📦 PSR-11 Compliant: Standard container interface for interoperability
  • Performance Optimized: Built-in caching, warmup, and a compiled cache that skips reflection
  • 🧩 Fluent Registration: Register bindings after construction with bind() and singleton()
  • 🎁 Typed Resolution: make() returns a typed instance; getOrFail() never returns null
  • 🔍 Introspection: Debug and inspect container state easily
  • 🎯 Type Safe: Requires type hints for reliable dependency resolution
  • 🏷️ PHP 8 Attributes: Declarative configuration with #[Inject], #[Singleton], and #[Factory]

Installation

composer require gacela-project/container

Requires PHP >= 8.1.

Hello World

use Gacela\Container\Container;

class Greeter {
    public function __construct(private Clock $clock) {}

    public function greet(): string {
        return 'Hello World at ' . $this->clock->now();
    }
}

class Clock {
    public function now(): string {
        return date('H:i:s');
    }
}

// Zero configuration — dependencies are auto-wired from type hints
$container = new Container();
$greeter = $container->make(Greeter::class);

echo $greeter->greet();

Need interfaces, singletons, attributes, or a compiled cache? See the docs below.

Documentation

Guide What's inside
Getting Started Installation, basic usage, how resolution works
Bindings & Registration Constructor bindings, bind()/singleton(), contextual bindings, aliasing
Resolving Services get(), make(), getOrFail(), resolve(), transient vs. shared
PHP 8 Attributes #[Inject], #[Singleton], #[Factory]
Managing Services Factories, extending, protecting closures, introspection
Performance & Compilation warmUp(), compiled container cache
Error Handling Error messages and what they mean
Best Practices Recommended patterns
API Reference Full method, static, and attribute reference

Real-World Example

See how it's used in the Gacela Framework.

Testing

composer test          # Run tests
composer quality       # Run static analysis
composer test-coverage # Generate coverage report

License

MIT License. See LICENSE file for details.