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(11mo ago)16613Apache-2.0PHPPHP ^8.2

Since Oct 31Pushed 6mo 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 1mo ago

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

35

—

LowBetter than 80% of packages

Maintenance60

Regular maintenance activity

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

354d ago

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

0.1.1PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/ae8591a5d36c52794b3fbc72b1d4199edc62984305386ff65dd97e399137b21f?d=identicon)[chengyao](/maintainers/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.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86787.8M343](/packages/league-container)[php-di/php-di

The dependency injection container for humans

2.8k48.9M994](/packages/php-di-php-di)[aura/di

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

356968.3k58](/packages/aura-di)[league/tactician-container

Tactician integration for any container implementing PSR-11

7710.1M23](/packages/league-tactician-container)[acclimate/container

Provides adapters for various third-party service containers.

219390.6k15](/packages/acclimate-container)

PHPackages © 2026

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