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

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

pkerrigan/di
============

A lightweight dependency injector

v2.0.1(1y ago)092BSD-3-ClausePHPPHP &gt;=8.4CI failing

Since Nov 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/patrickkerrigan/php-di)[ Packagist](https://packagist.org/packages/pkerrigan/di)[ RSS](/packages/pkerrigan-di/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (9)Dependencies (2)Versions (10)Used By (0)

[![Build Status](https://camo.githubusercontent.com/4a0216b926144c0c5bf1c4c44fd107083e8435749049fe7b7fee60745ce490f7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7061747269636b6b6572726967616e2f7068702d64692f54657374732e7376673f7374796c653d666c61742d737175617265)](https://github.com/patrickkerrigan/php-di/actions/workflows/tests.yml) [![Code Climate](https://camo.githubusercontent.com/0fe9439dcffdae9a47c4c0c02d355ccf1fee856835fef0d94a2dd62dcd33816a/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f7061747269636b6b6572726967616e2f7068702d64692e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/patrickkerrigan/php-di) [![Coverage](https://camo.githubusercontent.com/289ec6514f8c942cf2767709a458f6eeddc4b02934f444c80e3c169160b5f589/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f632f7061747269636b6b6572726967616e2f7068702d64692e7376673f7374796c653d666c61742d737175617265)](https://codeclimate.com/github/patrickkerrigan/php-di) [![PHP 8.4](https://camo.githubusercontent.com/2cf66bfcecdfc0efcfb81eb3b5346ff814d5719db617c74948ed0df16e0b9c2a/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d382e342d626c75652e7376673f7374796c653d666c61742d737175617265)](http://php.net/) [![Packagist](https://camo.githubusercontent.com/074ce694a6a13edccc0dfeef58ae6b1c51e1c983fe97fe81650587c1bbf99beb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706b6572726967616e2f64692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/pkerrigan/di)

pkerrigan/di
============

[](#pkerrigandi)

A simple, lightweight PHP 8.4 dependency injector.

Why?
----

[](#why)

This was for fun, and doesn't really compare to the features offered by the popular dependency injectors. If you just need to inject objects then you may find this useful.

Usage
-----

[](#usage)

```
$injector = Injector::getInstance();

$injector->addClassResolver(new ArrayMapClassResolver([
    Interface::class => ConcreteImplementation::class
]));

$instance = $injector->get(Interface::class);
```

By default, all objects are treated as lazy singletons (that is, the same object will be returned for successive calls to `get()`). If you wish an object to be constructed again for every call of get (or injection) then you can explicitly define it as a `Prototype` like so:

```
$injector->addClassResolver(new ArrayMapClassResolver([
    Interface::class => new Prototype(ConcreteImplementation::class)
]));
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity86

Battle-tested with a long release history

 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

Every ~322 days

Recently: every ~548 days

Total

9

Last Release

525d ago

Major Versions

v1.1.4 → v2.0.02024-12-07

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v2.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/3968064339c2d1293cff71ca9b0a392d971820a979deb2b0c77070dc5e57595a?d=identicon)[patrickkerrigan](/maintainers/patrickkerrigan)

---

Top Contributors

[![patrickkerrigan](https://avatars.githubusercontent.com/u/20188719?v=4)](https://github.com/patrickkerrigan "patrickkerrigan (29 commits)")

---

Tags

containerdependency-injectiondipsr11injector

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)[slince/di

A flexible dependency injection container

20260.4k6](/packages/slince-di)[capsule/di

A PSR-11 compliant autowiring dependency injection container.

2857.5k2](/packages/capsule-di)[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)

PHPackages © 2026

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