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

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

capsule/di
==========

A PSR-11 compliant autowiring dependency injection container.

4.0.1(1y ago)2857.5k—1.7%3[2 issues](https://github.com/capsulephp/di/issues)2MITPHPPHP ^8.1CI passing

Since Dec 5Pushed 1y ago5 watchersCompare

[ Source](https://github.com/capsulephp/di)[ Packagist](https://packagist.org/packages/capsule/di)[ RSS](/packages/capsule-di/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (17)Used By (2)

Capsule 4.x
===========

[](#capsule-4x)

Capsule is a [PSR-11 (2.0)](https://www.php-fig.org/psr/psr-11/) compliant autowiring dependency injection container with object-oriented configuration of constructor arguments and initialization methods, along with lazy resolution of arguments from various sources. Intended primarily for object entries, Capsule makes allowance for storing value entries as well.

Capsule is fully documented at .

What Capsule Supports
---------------------

[](#what-capsule-supports)

Capsule offers the ability to:

- create, modify, retain, and return objects and values via autowiring;
- configure and define that creation, modification, and retention logic;
- inject those objects and values into their dependent objects; and,
- lazy-resolve values and objects at instantiation time.

What Capsule Does Not Support
-----------------------------

[](#what-capsule-does-not-support)

Capsule does not offer:

- **Annotations and attributes.** Annotations and attributes tend to couple a service to a particular container implementation; I think that kind of coupling is wise to be avoid on principle.
- **Caching and compiling.** These are nominally performance enhancers, but in my experience they are rarely necessary, and in those rare cases the available speed increases are miniscule compared to other opportunities for optimization (e.g. database queries).
- **File-based configuration.** Capsule configuration is defined exclusively via object-oriented PHP code, not via Neon/YAML/XML files or PHP arrays. (As a corollary, there is no special configuration notation to learn for Capsule, only class methods.)
- **In-flight container modification.** This means you cannot set or reset new object or value definitions once a Capsule container is instantiated. (There are ways to subvert this restriction, in which case you will get what you deserve.)
- **Invocation injection.** Also called method-call injection or action injection, I think this feature lies outside the scope of a DI/IOC system.
- **Tagging.** I am ambivalent toward tagging; while I think it is little outside the scope of a DI/IOC system, I can see where others might find it useful. Perhaps a future version of Capsule may include it.

These missing features may be deal-breakers for some developers, in which case they have hundreds of autowiring and non-autowiring DI/IOC systems to choose from, including ...

- [Aura](https://github.com/auraphp/Aura.Di)
- [Auryn](https://github.com/rdlowrey/auryn)
- [Caplet](https://github.com/pmjones/caplet)
- [Laminas](https://docs.laminas.dev/laminas-servicemanager/) (nee Zend)
- [Laravel](https://laravel.com/docs/8.x/container)
- [League](https://container.thephpleague.com/)
- [Nette](https://doc.nette.org/en/3.0/dependency-injection)
- [PHP-DI](https://php-di.org/)
- [Symfony](https://symfony.com/doc/current/service_container.html)
- [Unbox](https://github.com/mindplay-dk/unbox)

... among other [DI](https://packagist.org/?query=dependency)and [IOC](https://packagist.org/?query=ioc) packages.

###  Health Score

48

—

FairBetter than 95% of packages

Maintenance45

Moderate activity, may be stable

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% 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 ~123 days

Recently: every ~144 days

Total

17

Last Release

388d ago

Major Versions

1.x-dev → 3.0.02021-08-19

3.4.1 → 4.0.02023-09-26

PHP version history (4 changes)2.0.0PHP &gt;=7.2

1.x-devPHP &gt;=7.1

3.0.0PHP ^8.0

4.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25754?v=4)[Paul M. Jones](/maintainers/pmjones)[@pmjones](https://github.com/pmjones)

---

Top Contributors

[![pmjones](https://avatars.githubusercontent.com/u/25754?v=4)](https://github.com/pmjones "pmjones (36 commits)")[![harikt](https://avatars.githubusercontent.com/u/120454?v=4)](https://github.com/harikt "harikt (3 commits)")

---

Tags

containerdependencyinjectiondependency-injectiondiiocinversion of control

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[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)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)[miladrahimi/phpcontainer

Dependency injection (IoC) container for PHP projects

1322.7k2](/packages/miladrahimi-phpcontainer)

PHPackages © 2026

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