PHPackages                             aicrion/container - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. aicrion/container

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

aicrion/container
=================

A modern high-performance dependency injection and service container for PHP 8.5+

v1.0.0(today)101MITPHPPHP &gt;=8.5CI passing

Since Jul 31Pushed todayCompare

[ Source](https://github.com/Aicrion/container-php)[ Packagist](https://packagist.org/packages/aicrion/container)[ Docs](https://github.com/aicrion/container-php)[ RSS](/packages/aicrion-container/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (7)Versions (2)Used By (1)

Aicrion Container
=================

[](#aicrion-container)

A modern, high-performance, PSR-11 compatible Dependency Injection Container for PHP 8.5+, built for real-world dependency graphs — including circular dependencies — with a clean, pipeline-based resolution engine.

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/36b923864f3d5c2cd2af63b7f31d4c9458f3d62a66ecab2c9f747b7981009026/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e352d3737376262342e737667)](composer.json)

Why another container?
----------------------

[](#why-another-container)

Existing containers (Symfony DI, PHP-DI, Laravel Container) are excellent, but they share a common limitation: **constructor-only injection cannot cleanly solve circular dependency graphs** without resorting to opaque proxy magic. Aicrion Container solves this natively with a **lifecycle-based injection model**:

1. `instantiate()` — the object is created (constructor injection happens here).
2. `injectDependencies()` — post-construction injection, safe for circular graphs.
3. `onReady()` — a lifecycle hook fired once, after all injection is complete.

Features
--------

[](#features)

- PSR-11 `ContainerInterface` compliant
- Constructor injection with automatic reflection-based resolution
- Post-construction injection for circular dependency graphs
- Service lifecycle: `instantiate → injectDependencies → onReady`
- Singletons, factories, transients, scoped services
- Aliases, tags/groups, decorators (`extend`)
- Lazy loading via virtual proxies
- Attributes: `#[Inject]`, `#[Singleton]`, `#[Factory]`, `#[Bind]`, `#[Tag]`, `#[Lazy]`
- Pipeline-based, fully extensible resolution engine
- Before/after resolve hooks
- Dependency graph analyzer (export to DOT/Graphviz)
- Beautiful, actionable exceptions
- Container compilation for reflection-free production performance
- Child containers with scoped overrides
- Contextual binding (`when()->needs()->give()`)
- Service providers with register/boot lifecycle
- WeakMap-backed scoped services (auto-released, no manual reset)
- CLI tools: `container-inspect`, `container-warmup`
- `#[Autowire]` for fine-grained parameter/property overrides (services, env vars, literals)
- `#[Autoconfigure]` for interface-driven tagging and lifetime configuration

Quick start
-----------

[](#quick-start)

```
composer require aicrion/container
```

```
use Aicrion\Container\Container;

$container = new Container();

$container->singleton(Logger::class);
$container->bind(LoggerInterface::class, Logger::class);
$container->alias('logger', LoggerInterface::class);

$userService = $container->make(UserService::class);
```

### Solving circular dependencies

[](#solving-circular-dependencies)

```
use Aicrion\Container\Service;

class ServiceA extends Service
{
    public ServiceB $b;

    public function injectDependencies(ServiceB $b): void
    {
        $this->b = $b;
    }
}

class ServiceB extends Service
{
    public ServiceA $a;

    public function injectDependencies(ServiceA $a): void
    {
        $this->a = $a;
    }
}

$container->singleton(ServiceA::class);
$container->singleton(ServiceB::class);

$a = $container->make(ServiceA::class); // fully wired, no exceptions
```

Documentation
-------------

[](#documentation)

Full documentation is available at  and in the [docs](docs/) directory.

License
-------

[](#license)

MIT © [Hadi Akbarzadeh](https://elatel.ir)

Benchmarks
----------

[](#benchmarks)

Aicrion Container was benchmarked against Symfony DependencyInjection, PHP-DI, and Laravel's Illuminate Container on the same PHP 8.5.8 machine (10,000 revs x 5 iterations per subject). Full methodology and raw output: [`benchmarks/RESULTS.md`](benchmarks/RESULTS.md).

**Live resolution** (no ahead-of-time compilation):

ContainerConstructor injectionSingleton lookupSymfony DependencyInjection0.195us0.190usPHP-DI1.478us--Laravel Illuminate Container2.546us0.316us**Aicrion Container****5.616us****1.510us****Compiled resolution** (ahead-of-time optimization):

ContainerConstructor injectionSingleton lookupSymfony DependencyInjection (compiled)0.183us0.183us**Aicrion Container (compiled)****0.599us****0.283us**Compiling Aicrion Container's definitions delivers a **~9.4x speedup** on constructor injection and **~5.3x** on singleton lookups over live reflection-based resolution.

Run the benchmarks yourself:

```
composer install
composer benchmark
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance100

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12207627?v=4)[Hadi Akbarzadeh](/maintainers/nabeghe)[@nabeghe](https://github.com/nabeghe)

---

Top Contributors

[![nabeghe](https://avatars.githubusercontent.com/u/12207627?v=4)](https://github.com/nabeghe "nabeghe (2 commits)")

---

Tags

dependency-injectiondiphpphp-php-containerphp-diphp-di-containerphp-service-containerphplibphplibrarypsr-11service-containerphpcontainerPSR-11dependency-injectiondiservice container

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/aicrion-container/health.svg)

```
[![Health](https://phpackages.com/badges/aicrion-container/health.svg)](https://phpackages.com/packages/aicrion-container)
```

###  Alternatives

[infocyph/intermix

A lightweight PHP DI container, invoker, serializer, and utility toolkit.

137.7k3](/packages/infocyph-intermix)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
