PHPackages                             kaihempel/simpledi - 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. kaihempel/simpledi

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

kaihempel/simpledi
==================

Simple dependency injection container

1.1.0(9y ago)334BSD-3-ClausePHPPHP &gt;=5.4.0

Since Oct 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/kaihempel/simpledi)[ Packagist](https://packagist.org/packages/kaihempel/simpledi)[ Docs](https://dev.kuweh.de/)[ RSS](/packages/kaihempel-simpledi/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

simpledi
========

[](#simpledi)

Simple PHP dependency injection bundle

[![Build Status](https://camo.githubusercontent.com/44a68597327303fe0e98921410e0299a274c480a890af618b245b4778cfe9585/68747470733a2f2f7472617669732d63692e6f72672f6b616968656d70656c2f73696d706c6564692e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/kaihempel/simpledi)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/1fca815de9332c20cce0dcc91fa1ffed226aa078d321ffda73945338840e4659/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b616968656d70656c2f73696d706c6564692f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kaihempel/simpledi/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a8f51065189c09d96357ac3caf10089a8a1f150162e9105656510b10838b2c9c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6b616968656d70656c2f73696d706c6564692f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/kaihempel/simpledi/?branch=master)

This dependency injection container based on the idea to add the object construction code as closure. So every dependency can build with less convention restrictions.

Installing simpledi via Composer.

```
  "require": {
    "kaihempel/simpledi": "1.1.*"
  }
```

Create the dependency injection container instance:

```
  $di = new \SimpleDI\SimpleDI();
```

Adding closures for instance creation:

```
  $di->add('author', function($name) {
    return new Author($name);
  });
```

After adding the closure with the name "autor", the closure can be executed by calling the magic get method:

```
  $author = $di->getAuthor($name);
```

To create instance with further dependencys, the dependency injection container can be commited to the closure by using the "use" keyword:

```
  $di->add('book', function($name) use ($di) {
    return new Book($di->getAuthor($name));
  });
```

Like the description above, the "Book" instance will be initialized with a new author instance.

The container has a storage to save created objects. This feature have to be enabled by calling the "getStored()" method before calling the closure code:

```
  $storedBook = $di->getStored()
                   ->getBook($name);
```

If no Book instance is stored, the closure execution saves the new instance in the storage.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~86 days

Total

4

Last Release

3594d ago

Major Versions

0.1.1 → 1.0.02016-04-03

### Community

Maintainers

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

---

Top Contributors

[![kaihempel](https://avatars.githubusercontent.com/u/7288789?v=4)](https://github.com/kaihempel "kaihempel (37 commits)")

---

Tags

dependency-injection

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kaihempel-simpledi/health.svg)

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

###  Alternatives

[php-di/invoker

Generic and extensible callable invoker

26857.8M56](/packages/php-di-invoker)[level-2/dice

A minimalist Dependency injection container (DIC) for PHP. Please note: 3.0+ is only compatible with PHP 7.0. The 2.0 branch is compatbile with PHP 5.6.

437730.3k17](/packages/level-2-dice)[respect/config

A powerful, small, deadly simple configurator and dependency injection container made to be easy.

10211.4k1](/packages/respect-config)[arokettu/phpstorm-metadata-export

Export PhpStorm Advanced Metadata from DI containers

1234.0k1](/packages/arokettu-phpstorm-metadata-export)[x-wp/di

The dependency injection container for WordPress

301.1k10](/packages/x-wp-di)[michaels/data-manager

Simple data manager for nested data, dot notation array access, extendability, and container interoperability.

121.9k2](/packages/michaels-data-manager)

PHPackages © 2026

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