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
Fund package maintenance!
0.10.0
2026-07-19 22:59 UTC
Requires
- php: >=8.1
- psr/container: >=1.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- phpstan/phpstan: ^1.12
- phpunit/phpunit: ^10.5
- psalm/plugin-phpunit: ^0.18
- symfony/var-dumper: ^5.4
- vimeo/psalm: ^5.26
This package is auto-updated.
Last update: 2026-07-19 23:16:11 UTC
README
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()andsingleton() - 🎁 Typed Resolution:
make()returns a typed instance;getOrFail()never returnsnull - 🔍 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.