PHPackages                             wptechnix/di-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. wptechnix/di-container

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

wptechnix/di-container
======================

A minimal, explicit PSR-11 dependency injection container for PHP.

v1.0.0(1mo ago)05MITPHPPHP ^8.0CI passing

Since Jul 1Pushed 4w agoCompare

[ Source](https://github.com/WPTechnix/di-container)[ Packagist](https://packagist.org/packages/wptechnix/di-container)[ RSS](/packages/wptechnix-di-container/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

WPTechnix DI
============

[](#wptechnix-di)

[![Packagist Version](https://camo.githubusercontent.com/955eeb59500acf498f2b03d72ea4354ada436d03f31135409e3f10251f81b44b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7770746563686e69782f64692d636f6e7461696e6572)](https://packagist.org/packages/wptechnix/di-container)[![PHP 8.0+](https://camo.githubusercontent.com/40f50455222eeef8f2b102965352d143bcbcc1c290574cb23ea6d5e2a2b710ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d383839326266)](https://camo.githubusercontent.com/40f50455222eeef8f2b102965352d143bcbcc1c290574cb23ea6d5e2a2b710ef/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d383839326266)[![PSR-11](https://camo.githubusercontent.com/59cea7fda73264c709cb8f0716566dc3c480ebad4cc9fe0f87788c1850513936/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d31312d2545322539432539332d627269676874677265656e)](https://camo.githubusercontent.com/59cea7fda73264c709cb8f0716566dc3c480ebad4cc9fe0f87788c1850513936/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5053522d2d31312d2545322539432539332d627269676874677265656e)[![MIT](https://camo.githubusercontent.com/b8cadaa967891081f8f165695470689986c028821dd8a040132f6e661795dc0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c7565)](https://camo.githubusercontent.com/b8cadaa967891081f8f165695470689986c028821dd8a040132f6e661795dc0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c7565)

A minimal, explicit PSR-11 dependency injection container for PHP.
No autowiring, no reflection, no magic — what you register is exactly what you get.

Installation
------------

[](#installation)

```
composer require wptechnix/di
```

Quick Start
-----------

[](#quick-start)

### 1. Create the container

[](#1-create-the-container)

```
use WPTechnix\DI\Container;

$container = new Container();
```

### 2. Register a singleton (shared service)

[](#2-register-a-singleton-shared-service)

Singletons are created once and cached. Perfect for stateless services like loggers, database connections, or configuration readers.

```
use Psr\Log\LoggerInterface;
use App\Logging\FileLogger;

$container->singleton(LoggerInterface::class, FileLogger::class);
```

Now every time you ask for `LoggerInterface::class` you get the same `FileLogger` instance.

### 3. Register a factory (new instance each time)

[](#3-register-a-factory-new-instance-each-time)

Use factories when each resolution needs a fresh object, for example a mailer that picks up current settings, a report generator that depends on the current user, or any stateful helper.

```
use App\Reporting\ReportGenerator;
use App\Context\CurrentUser;

$container->factory(ReportGenerator::class, function (Container $c) {
    return new ReportGenerator($c->get(CurrentUser::class));
});
```

Every call to `$container->get(ReportGenerator::class)` gives you a brand new `ReportGenerator`.

### 4. Resolve services

[](#4-resolve-services)

```
$logger = $container->get(LoggerInterface::class);   // FileLogger instance (cached)
$report = $container->get(ReportGenerator::class);    // Fresh ReportGenerator each time
```

Check if a service exists before resolving:

```
if ($container->has(LoggerInterface::class)) {
    // ...
}
```

More Features
-------------

[](#more-features)

- **Aliases** — point one identifier to another.

    ```
    $container->alias('log', LoggerInterface::class);
    $container->get('log'); // same FileLogger instance
    ```
- **Constructor parameters** — pass primitive values or other services fluently.
- **Tags** — group related services and resolve them all at once.
- **Extenders** — decorate a service before its first resolution.
- **Service providers** — two‑phase bootstrapping for large applications.

See the **[Getting Started](docs/Home.md)** guide for a full walkthrough, or browse the other docs:

- [Core Concepts](docs/Core-Concepts.md)
- [Constructor Parameters](docs/Constructor-Parameters.md)
- [Tagging](docs/Tagging.md)
- [Extending Services](docs/Extending-Services.md)
- [Service Providers](docs/Service-Providers.md)
- [API Reference](docs/API-Reference.md)

Requirements
------------

[](#requirements)

- PHP 8.0 or later
- `psr/container` ^1.1 || ^2.0

License
-------

[](#license)

MIT

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance93

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 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

43d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e0fb168547a02b4a7b28df9403ab375f354591c75e814dce020f245e77f04e5f?d=identicon)[owaisahmed5300](/maintainers/owaisahmed5300)

---

Top Contributors

[![owaisahmed5300](https://avatars.githubusercontent.com/u/28684548?v=4)](https://github.com/owaisahmed5300 "owaisahmed5300 (11 commits)")

---

Tags

containerdependency-injectiondiiocpsr-11service-providercontainerPSR-11dependency-injectiondiiocservice provider

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

2.8k58.2M1.3k](/packages/php-di-php-di)[slince/di

A flexible dependency injection container

20277.1k6](/packages/slince-di)[infocyph/intermix

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

138.8k4](/packages/infocyph-intermix)

PHPackages © 2026

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