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

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

dida/container
==============

The Container Component of Dida Framework

v0.1.1(6y ago)011MITPHPPHP ^5.5 || ^7.0

Since Dec 4Pushed 6y agoCompare

[ Source](https://github.com/zeupin/dida-container)[ Packagist](https://packagist.org/packages/dida/container)[ Docs](https://github.com/zeupin/dida-container)[ RSS](/packages/dida-container/feed)WikiDiscussions master Synced 6d ago

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

Dida\\Container 组件
==================

[](#didacontainer-组件)

`Dida\Container` 是一个容器类，可以为 App 提供懒加载、依赖注入和服务定位功能。它是 [宙品科技](http://zeupin.com) 开源的 [Dida 框架](http://dida.zeupin.com) 的一个容器功能组件。

- 源码

遵循的规范
-----

[](#遵循的规范)

- PSR-11 容器接口规范
    官方:
    中文翻译: 。

支持三种服务类型
--------

[](#支持三种服务类型)

- 类名 -- `CLASSNAME_TYPE`
- 闭包函数 -- `CLOSURE_TYPE`
- 服务实例 -- `INSTANCE_TYPE`

> 本质上，每一个服务条目都是一个对象实例。

API
---

[](#api)

- `has($id)` -- 是否存在某个服务
- `set($id, $service)` -- 设置一个服务
- `setSingleton($id, $service)` -- 设置一个单例服务
- `get($id)` -- 获取一个共享的服务实例
- `getShared($id, array $parameters = [])` -- 获取一个共享的服务实例
- `getNew($id, array $parameters = [])` -- 获取一个新的服务实例（不可用于 Singleton 服务，否则会抛出异常）
- `remove($id)` -- 删除一个服务
- `keys()` -- 获取所有已注册的服务 id

作者
--

[](#作者)

- [Macc Liu](https://github.com/maccliu)，欢迎 follow。

感谢
--

[](#感谢)

- [宙品科技，Zeupin LLC](http://zeupin.com) , 尤其是 [Dida 框架团队](http://dida.zeupin.com)

版权声明
----

[](#版权声明)

版权所有 (c) 上海宙品信息科技有限公司。
Copyright (c) Zeupin LLC.

源代码采用 MIT 授权协议。
Licensed under The MIT License.

如需在您的项目中使用，必须保留本源代码中的完整版权声明。
Redistributions of files MUST retain the above copyright notice.

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

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

2357d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22cf1a638337842f99374a665fbf29414b5ef626808f75c9816ca1afcb7e2dfc?d=identicon)[dida](/maintainers/dida)

---

Top Contributors

[![maccliu](https://avatars.githubusercontent.com/u/2162090?v=4)](https://github.com/maccliu "maccliu (5 commits)")

---

Tags

containerPSR-11Dida

### Embed Badge

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

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

###  Alternatives

[php-di/php-di

The dependency injection container for humans

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

A flexible dependency injection container

20260.4k6](/packages/slince-di)[chubbyphp/chubbyphp-container

A simple PSR-11 container implementation.

1978.4k14](/packages/chubbyphp-chubbyphp-container)[phpwatch/simple-container

A fast and minimal PSR-11 compatible Dependency Injection Container with array-syntax and without auto-wiring

1810.1k2](/packages/phpwatch-simple-container)[selective/container

A simple PSR-11 container implementation with autowiring.

1220.4k4](/packages/selective-container)[devanych/di-container

Simple implementation of a PSR-11 dependency injection container

124.2k3](/packages/devanych-di-container)

PHPackages © 2026

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