This tiny library aims to provide a dead-simple PSR-11 implementation with flexible service registration.
- PSR-11 Compliant: Fully implements the PSR-11
ContainerInterface. - Autowiring: Automatically resolves dependencies for constructors and callables using type-hints or parameter names.
- Flexible Registration: Register services using closures, class names, functions, invokable objects, or class-method pairs — pre-built instances go in through
fn () => $instanceor anEntryFactory. - Service Extension: Easily modify or wrap existing services using the
extend()method. - On-the-fly Resolution: Build fresh, uncached values from a registered entry, a class name, or any callable using
make()— nothing is stored and no events fire. - PSR-14 Event Lifecycle: Dispatches readonly, observe-only
EntryRegisteredandEntryResolvedevents through PSR-14 interfaces, with a minimalist built-in dispatcher for zero-configContainerAwareinjection. - Container Awareness: Automatically inject the container into services that implement
ContainerAware. - Lightweight: Minimal dependencies (only PSR-11 and PSR-14 interfaces) and a small footprint.
Use Composer
$ composer require projek-xyz/container --prefer-distDocumentations and usages available on wiki
This library is open-sourced software licensed under MIT license.