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

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

next/di
=======

A lightweight dependency injection tool, container based on the PSR-11 specification.

0.2.0(1y ago)16813Apache-2.0PHPPHP ^8.2

Since Oct 31Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/next-laboratory/di)[ Packagist](https://packagist.org/packages/next/di)[ Docs](https://github.com/next-laboratory/di)[ RSS](/packages/next-di/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (4)Used By (3)

一款简单的容器，所有被容器实例化的类以及所有依赖都是单例

安装
==

[](#安装)

> 环境要求 PHP &gt;= 8.0

```
composer require next/di
```

使用
==

[](#使用)

获取容器实例，注意不要直接实例化

```
$container = \Next\Di\Context::getContainer();
$container = container();
```

绑定类和别名，之后所有容器接口都可以使用TestInterface::class标识来获取Test::class实例

```
$container->bind(TestInterface::class, Test::class);
```

实例化

```
$container->make(Test::class);
```

获取对象

```
$container->get(Test::class);
```

调用方法

```
$conatiner->call(callable $callable, array $arguments = []);
```

> 注意：所有需要传参的api均需要关联数组，数组的键为参数的名字

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance55

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.4% 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

Every ~288 days

Total

3

Last Release

400d ago

PHP version history (2 changes)0.1PHP ^8.0|^8.1

0.1.1PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1903831?v=4)[chengyao](/maintainers/chengyao)[@Chengyao](https://github.com/Chengyao)

---

Top Contributors

[![bbuugg](https://avatars.githubusercontent.com/u/64066545?v=4)](https://github.com/bbuugg "bbuugg (38 commits)")[![zds-s](https://avatars.githubusercontent.com/u/49744633?v=4)](https://github.com/zds-s "zds-s (1 commits)")

---

Tags

annotationcontainerdicontainernextphpdependence injection

### Embed Badge

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

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

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k134.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86894.4M441](/packages/league-container)[aura/di

A serializable dependency injection container with constructor and setter injection, interface and trait awareness, configuration inheritance, and much more.

356990.7k60](/packages/aura-di)[gacela-project/container

A minimalistic container dependency resolver

11147.7k4](/packages/gacela-project-container)[infocyph/intermix

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

137.7k2](/packages/infocyph-intermix)

PHPackages © 2026

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