PHPackages                             reaway/think-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. reaway/think-container

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

reaway/think-container
======================

think container

v8.0.0(2w ago)047↓36.2%1Apache-2.0PHPPHP &gt;=8.0

Since Mar 8Pushed 2w agoCompare

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

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

think-container
===============

[](#think-container)

安装
--

[](#安装)

```
composer require reaway/think-container
```

特性
--

[](#特性)

- 支持PSR-11规范
- 支持依赖注入
- 支持容器对象绑定
- 支持闭包绑定
- 支持接口绑定

Container
---------

[](#container)

```
use Think\Component\Container\Container;

// 获取容器实例
$container = Container::getInstance();
// 绑定一个类、闭包、实例、接口实现到容器
$container->bind('cache', '\app\common\Cache');
// 判断是否存在对象实例
$container->has('cache');
// 从容器中获取对象的唯一实例
$container->get('cache');
// 从容器中获取对象，没有则自动实例化
$container->make('cache');
// 删除容器中的对象实例
$container->delete('cache');
// 执行某个方法或者闭包 支持依赖注入
$container->invoke($callable, $vars);
// 执行某个类的实例化 支持依赖注入
$container->invokeClass($class, $vars);
// 静态方法获取容器对象实例 不存在则自动实例化
Container::pull('cache');
```

对象化操作

```
use Think\Component\Container\Container;

// 获取容器实例
$container = Container::getInstance();
// 绑定一个类、闭包、实例、接口实现到容器
$container->cache = '\app\common\Cache';
// 判断是否存在对象实例
isset($container->cache);
// 从容器中获取对象的唯一实例
$container->cache;
// 删除容器中的对象实例
unset($container->cache);
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance97

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

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

14d ago

### Community

Maintainers

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

---

Top Contributors

[![reaway](https://avatars.githubusercontent.com/u/60423559?v=4)](https://github.com/reaway "reaway (1 commits)")

### Embed Badge

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

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

###  Alternatives

[internal/dload

Downloads binaries.

97124.8k6](/packages/internal-dload)[topthink/think-container

PHP Container &amp; Facade Manager

18254.1k26](/packages/topthink-think-container)

PHPackages © 2026

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